Re: Translate curl command to NSURLRequest
Re: Translate curl command to NSURLRequest
- Subject: Re: Translate curl command to NSURLRequest
- From: Jens Alfke <email@hidden>
- Date: Sat, 04 Jul 2015 14:03:03 -0700
> On Jul 4, 2015, at 11:04 AM, Rick Mann <email@hidden> wrote:
>
> FWIW, you're setting the Accept header, not Content-Type (nor Accept-Language).
Yup. And I’m pretty sure you [the OP] don’t want to add that Accept header to all requests, since it’s telling the server to give up (with a 406 status) if the response type isn’t application/xml. Generally you only want to use an Accept header for requests whose body will have a response, and which response can optionally be delivered with different content types. For example an API that lets you download an image as either JPEG or PNG.
Instead you want to set the Content-Type for this request, and just add that header to the one request you’re sending.
(Sending a GET request with a body is pretty unusual, but I assume that’s what the server wants since you say the curl command works…)
Also +1 to taking this to macnetworkprog.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden