I was looking for a method to execute this
curl -u username:password -H "Content-Type: application/binary" \
--data-binary @file.dat -X POST \
"https://helpdesk.zendesk.com/api/v2/uploads.json?filename=myfile.dat&token={optional_token}"
I tried using this
[afnetworkmanager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:attachment.attachmentData name:@"image" fileName:attachment.fileName mimeType:attachment.mimeType];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
// TODO:
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// TODO:
}];
But it did not help. Currently I am getting an error saying
{
> "Cache-Control" = "max-age=0, private, must-revalidate";
> Connection = "keep-alive";
> "Content-Length" = 345;
> Server = "nginx/1.4.2";
> Status = "201 Created";
> "X-Content-Type-Options" = nosniff;
> "X-Runtime" = "1.471856";
> "X-UA-Compatible" = "IE=Edge,chrome=1";
> "X-Zendesk-API-Version" = v2;
> "X-Zendesk-API-Warn" = "Removed restricted keys [\"image\"] from parameters according to whitelist"; } },
> NSLocalizedDescription=Request failed: unacceptable content-type:
> text/plain}
I dont understand where I am wrong.
I eventually got this to work by using the AFURLSessionManager. Here is the complete code: