• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RESTful Web Services & PUT
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RESTful Web Services & PUT


  • Subject: RESTful Web Services & PUT
  • From: Jeff LaMarche <email@hidden>
  • Date: Thu, 05 Jun 2008 10:13:45 -0400

I noticed that there's been some discussion of RESTful web services. I've been having problem with PUT requests using NSMutableURLRequest, one that has been asked about on the list before, but I never saw an answer or workaround posted. After some digging I found a workaround to my problem that I thought I'd share so that anyone searching the archives would find it.

The problem I've been experiencing is that when making an HTTP 1.1 PUT request, my form parameters passed in the request body are not being recognized by the web service. A little digging with wireshark showed that the reason for that is that NSMutableURLRequest is not setting the Content-Type parameter for PUT requests, though it is for POST requests. This missing header causes most web services to ignore the request body. The solution is to simply add the following line of code before sending it to the server (req is the NSMutableURLRequest):

[req setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];

This issue has been submitted to Apple as problem ID 5988016, but I thought I'd put the workaround here for anyone who's experiencing the problem:


_______________________________________________

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


  • Prev by Date: Newbie question:IB, NSView, NSViewController
  • Next by Date: IB label (textfield) as URL / mail-address how?
  • Previous by thread: Re: Newbie question:IB, NSView, NSViewController
  • Next by thread: Subject: Re: Keyboard Layout Services
  • Index(es):
    • Date
    • Thread