Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Http Post Example for xcode

Tags:

http

xcode

ios

I need a simple example where we POST some HTTP request to the server. And also i need to add some headers to that HTTP post. I have tried posting the HTTP post, but little confused about adding headers in the request. Is there any mandatory field/HEADER i have to add in the HTTP Post ??

like image 995
Cyril Avatar asked Jan 23 '26 10:01

Cyril


1 Answers

Suppose you have an NSURLRequest called theRequest.

You configure the request type to POST with

[theRequest setHTTPMethod:@"POST"];

And for the headers, you add values to the Header you add them as key value pairs:

[theRequest setValue:authorizationString forKey:@"Authorization"];

which sets authorizationString for the Authorization header.

like image 75
Abizern Avatar answered Jan 25 '26 10:01

Abizern



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!