How to format an HTTP PUT request? - objective-c

I am using the Yahoo Placemaker API and would like to send a request but I am getting confused as to how to send the request. The request is composed of a URL and a document and inside the document, there are a bunch of parameters. Please see below.
http://wherein.yahooapis.com/v1/document
documentContent=Sunnyvale+CA
documentType=text/plain
appid=my_appid
How do I format the URL into a request is it like so?
http://wherein.yahooapis.com/v1/documentContent=Sunnyvale+CA?documentType=text/plain?appid=my_appid
I would like to use this the Placemaker service for a Mac app written in objective-c.
Any suggestions would be great. Thanks.

You don't. The URI and the request body are different things.
It would be helpful if you explained why you're asking. What platform/API/language are you using?

Related

How to send post request using Spookyjs with body parameter?

I want to send a post request with JSON body to a particular server using Spookyjs. How I do that please help into this?
If you are using spooky, then you are using nodeJS. Gather your informations (which I'm guessing you want to do) with spooky / casper, pass them back to nodeJS, parse your data and post it.

what does POST stand for in an API header url?

I'm trying to access an API with the pattern POST /api/quotes/params?. . . and GET /api/quotes/3 but I don't know what the POST/GET are for. Am I supposed to replace them with something? I understand normal HTTP GET/POST requests but don't see the relevance in this caseā€¦ please help shed some light.
They are just normal HTTP methods. Generally, GET requests only fetch data, they don't modify anything on the server. POST requests are used to modify data by submiting a post body.
When should I use GET or POST method? What's the difference between them?
They just indicate how you should make your request and/or which methods are available for each endpoint.

Add a header to a page request using GET?

I have a vb.NET App that uses System.Net.WebClient to query an API. I'm able to get the information I'm requesting just fine.
The people that supply the API are requesting that I
"set a custom User header when requesting data to determine the source application."
Am I supposed to pre-send something first, or append something to the url for the WebClient to processes? The API only accepts get requests and it doesn't have a parameter for an identification.
I'm stuck in terminology here. A search for that phrase, here, came up with server-side topics so I don't know what to look for. Can someone translate?

Understanding the Reddit API - URL vs headers vs body

Here's the API.
This is my first time working with web APIs so bear with me. Where do the name-value pairs listed under each call belong in my HTTP request? Do they go in the URL, the headers, or the body? Is it different depending on if it's a GET request or a POST?
Are the answers to these questions true in general, i.e. for any web API?
Where do the name-value pairs listed under each call belong in my HTTP request?
In a GET, they're in the URL's query string. in a POST, they're in the request body. Headers never contain request parameters, but things like Content-length do control them, a bit. You might also run across JSON in a POST body (I can't remember if reddit does this). This is not reddit-specific, and is standard HTTP.

POSTing to web service API in Objective C?

I'm writing one of my first apps for consuming a web service in Objective C, it's a Lighthouse API client. I'm able to execute all the GETs and XML parsing correctly and quickly, but I'm having extreme trouble trying to create a new ticket via POST (http://lighthouseapp.com/api).
I'm using ASIHTTPRequest.
I tried including the parameters on the URL (i.e. POST /projects/#{project_id}/tickets.xml?title=boo).
I've tried putting the ticket XML in the request body.
<ticket><title>boo</title></ticket>
Nothing is working. (server always sends a response back saying it needs a title) I'm very new to web services - am I missing something obvious?
I had a quick look at the Lighthouse API and here's how you go about creating a new ticket.
Request URL is http://{yourCustomURL}.lighthouseapp.com/projects/{ProjectID}/tickets.xml where {ProjectID} is a 5 digit number - in my case 72945.
Method is POST
Content type should be set to application/xml
Body should be in the format below. All fields are optional so I only included the title
<ticket> <assigned-user-id type="integer"></assigned-user-id> <body></body> <milestone-id type="integer"></milestone-id> <state></state> <title>Testing new ticket creation</title></ticket>
(sorry about the formatting of the code above, SO doesn't seem to like XML formatted code somehow?
This worked for me with a new ticket created under projectID 72945 - response received was 201 Created
If you want to make sure your POST request is working before diving into ASIHTTPRequest, download a Firefox add-on called POSTER from here. This will allow you to send an authenticated post request with all the fields above. Once you get that working, it should be a piece of cake to get ASIHTTPRequest to do the same.