What annotation to use to define HTTP Request headers? - swagger

I've been searching the documentation but I can only find a annotation for Response request headers, but what is the annotation to use to define Request Headers?

Related

How to encode JSON as request parameter using Alamofire and AlamofireObjectMapper

I have a question about doing POST, PATCH, and PUT requests when using Alamofire and AlamofireObjectMapper. For example, lets say that I am doing a POST request to to send a object to a server. Can I pass a mapping as parameters for the request. Does it work similar to how RestKit encodes parameters into the body of the request as JSON?

How to transfer dynamic TokenHeader value in all requests instead of changing the value in every request's header in SOAPUI

I am new in SOAP UI. I have an one scenario like I have to pass the access token value coming as a response to all the requests under the test suite.I ADD this token value in the next request header field called "TokenHeader" and it is working but my query is there any method that I can add which can be applied for all the soap requests, instead of changing the value every time for all request's header.How to automate this?Please guide me on this.
Just tab header of each request and add
TokenHeader = ${TestStepname#Response#jsonpath}
It will send token (received from response json) to http header of other request.

Difference between AFJSONRequestSerializer and AFHTTPRequestSerializer

What actually is the reason that my request works for AFJSONRequestSerializer and doesnt for AFHTTPRequestSerializer?
I have set
responseSerializer.acceptableContentTypes?.insert("application/json")
for AFHTTPRequestSerializer and it doesn't work, but should.
I just send simple dictionary:
{
"approval_required" = 1;
birthdate = "2016-03-11";
gender = male;
name = Bartolo;
password = password1234;
username = "super user";
}
Here is similar question, but there is no explanation WHY it is like that.
Can anyone explain?
The acceptableContentTypes has little to do with the format of a request, ie whether it is HTTP request or JSON request. A request serializer's fundamental responsibility is to create a request in the specified format. Thus, the choice of requestSerializer dictates whether you are creating a HTTP request (e.g. a Content-Type of application/x-www-form-urlencoded) or JSON request (e.g. a Content-Type of application/json). The acceptableContentTypes merely allows the request to specify in what format(s) your app will accept responses. (And, frankly, you shouldn't specify acceptableContentTypes, but rather just use the correct responseSerializer.) But the request format and the accepted response format are two completely different things. In fact, it's not uncommon to have a web service that only accepts HTTP requests, and only provides JSON responses.
In your case, it sounds like you have a web service that is expecting a JSON request. When you specify AFHTTPRequestSerializer, the request will not be in JSON format and will likely not be understood. And specifying acceptableContentTypes does not alter the fact that the request, itself, isn't JSON.
By the way, tools like Charles or Wireshark are very useful for debugging network code, and would be illuminating in diagnosing the difference in these two types of requests. If you use one of these tools to watch the raw requests/responses, the difference will jump out at you.

iOS RestKit: How to make sure POST parameters are encoded in the request URL?

I'm trying to use RestKit because I'm expecting to make Core Data managed objects out of requests responses and it seemed like the framework was all about doing that and it seemed to be rather full featured.
But I'm having trouble getting my POST /user/login with parameters api_key=<value> (plus a separate JSON body) to end up a going out in a request like /user/login?api_key=<value>.
In the internals of RKObjectManager, requestWithMethod:path:parameters: does:
// NOTE: If the HTTP client has been subclasses, then the developer may be trying to perform signing on the request
NSDictionary *parametersForClient = [self.HTTPClient isMemberOfClass:[AFHTTPClient class]] ? nil : parameters;
request = [self.HTTPClient requestWithMethod:method path:path parameters:parametersForClient];
Do I have it right that this AFNetworking superclass method encodes parameters into the URL query? And does this mean the only way to ensure parameters are passed to that is to have my RKObjectManager use some subclass of AFHTTPClient?
And, according to the comment, supposedly this is only for sake of maybe a fringe case, something about request signing or something? Why is URL query-encoded request parameters not a common thing to do??
And getting things JSON encoded like I want does not seem to be as easy as I'd hoped either. Maybe it's a mistake for me to even try to use RestKit.

POST arbitrary text with AFNetworking

I have seen how you can POST urlencoded forms and json using HttpClient.
But how do I POST arbitrary text?
My use case is that I already have my JSON string created, so I want to post the string directly, instead of constructing a dictionary.
Set the HTTPBody property on NSMutableURLRequest, and use anywhere in AFNetworking that takes an NSURLRequest parameter.

Resources