cURL Multipart Post,如何包含Docebo API的文件

Edit:

I think I figured they want the key of the value containing the file.

So it should be:

$data = [
    "importMap" => "userid,firstname,lastname,email,new_password",
    "uploadedFileKey" => "@" . realpath("sample.csv"),
    "file_upload" => "uploadedFileKey",
    ...
];

Alas that returns a (Error 500), Ouch! Something went wrong! page. Probably that api method has been disabled.

/end edit

I'm working with the Docebo API and every call I'm sending works fine besides when I want to include a file.

I'm pretty sure I'm not adding the file correctly to the postfield array, but I cannot figure out what my error is.

The API is asking for:

UserApiModuleStartSynchSchema {
    importMap (Array[string]): Array of columns identifying the columns of the CSV file. For all allowed column names, see notes above. ,
    file_url (string, optional): Publicly accessible URL where the CSV file can be downloaded from ,
    file_upload (string, optional): The name of the uploaded CSV file (via multipart POST) ,
    ...
}

I'm sending in the postfields:

$data = [
    "importMap" => "userid,firstname,lastname,email,new_password",
    "file_upload" => "sample.csv",
    "file" => "@" . realpath("sample.csv"),
    ...
];

I made sure the file exists, the content is correct and that the correct encoding is used.

File content is:

userid,firstname,lastname,email,new_password
marysmith,Mary,Smith,marysmith@example.com,fi5Zd90S

To be able to use the API you have to create a Authorization header that includes all postfields like this implode(‘,’, $params). If I include my file there it will respond with a Authorization header value doesn't match if I include it after the header has been created it responds with Error while reading uploaded CSV file.

So I figured the second option would be the one to go, but I cannot figure out what made it fail reading the file.