I am using swagger 2.1.0. I am able to send a header in a request, thanks to this example.
But now my question, the key which is to send with this example-call is received in a header of the previous response. How can I read the headers of the previous response, so I can extract the value to send?
Maybe better, more simple: How can I read the headers which come with a response?
Related
I am using swagger openapi specification 3.0 to generate swagger from my interface. I have a delete method where it accepts request-body. But according to RFC7231, DELETE does not accept any request body. Also Swagger-request body tells that so. But my API is designed to accept request body in DELETE operation. Is there any work around in creating swagger such that DELETE operation accepts request body. Currently what error I am getting from swagger generation is,
Sematic error: DELETE operations cannot have a requestBody
No, you cannot use the OpenAPI 3.0 Specification and Swagger tools to implement DELETE requests with a request body. As you correctly pointed out, the HTTP RFC says the DELETE request body has no defined semantics (and thus should be avoided), and OpenAPI 3.0 specifically disallows bodies in HTTP methods where the body does not have defined semantics. See this discussion for some context.
Consider changing your API design, for example, replace the DELETE body with path, query string or header parameters. Check out RESTful Alternatives to DELETE Request Body for some ideas.
This type of operation (DELETE, GET requests with a body) was explicitly banned in Open API 3.0. Prior to that it was allowed or vague.
I am using
idhttp.Request.CustomHeaders.AddValue(x,y);
This is working fine for me, but now I have come across a different header and am not sure how to add it or what value, string to use.
In the past, I have used
'SOAPACTION','http://url/action'
But what would I need to do for the mustUnderstand part, or in the ReplyTo and Address parts?
How would I AddValue(x,y) them?
I have tried
...AddValue('SOAPACTION','http://URL/Action');
...AddValue('mustUnderstand','1');
But I am getting errors, and the host IT says that my headers are not correct.
<s:Header>
<a:Action s:mustUnderstand="1">http://URL/Action</a:Action>
<a:MessageID>A Valid GUIID</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">URL STRING</a:To>
</s:Header>
Previous simple headers have worked, but I am not sure how to add these headers.
SOAPAction is a valid HTTP header for SOAP messaging, but mustUnderstand and ReplyTo are not HTTP headers, so DO NOT add them with TIdHTTP.Request.CustomHeaders.AddValue() at all. They are components of the <Header> element inside of a SOAP <Envelope> message, so they belong inside the XML data that you post to the server via TIdHTTP (as per the example XML that you showed). You are confusing HTTP headers and SOAP headers. They are two different things.
If the webserver IT is telling you that your HTTP or SOAP headers are wrong, it should also be telling you what exactly is wrong with them so you can fix it.
This is not an Indy issue. You are simply not preparing your SOAP message the way the webserver is expecting. But we don't have those details to advise you with. The webserver IT does.
I would like to know if it is posible send a request with a JSON body and get the XML response with retrofit 2.
If I add two .addFactoryConverter() methods retrofit just use the first one for both the request and the response.
Thank you for your help.
With the following code I could solve the problem. https://github.com/square/retrofit/blob/master/samples/src/main/java/com/example/retrofit/JsonAndXmlConverters.java
first of all I'd like to thank the team for this amazing project, it is indeed exiting to be able to start writing server-side software in Swift.
I'm successfully running a POC using PerfectServer on an Ubuntu VM and working on the API to interact with the mobile client.
There is one aspect I didn't quite understand yet, and that is accessing the request body data from my PerfectServer Handler.
Here is the workflow I have in mind:
The client submits a POST request to PerfectServer including some
JSON encoded body data
Once that hits the "valuesForResponse:" of
my server side Handler, I retrieve the WebRequest representation of
my request successfully
The request object does expose a many
properties of the HTTP request, including headers and the url-like
formatted query parameters.
Unfortunately, I cannot see a way to retrieve the underlying request body data. I would expect that to be some kind of public properties exposing the raw data that my handle can retrieve and decode in order to process the request.
The only example provided in the Examples workspace that comes with the project and sends a POST request that includes a body is in the project Authenticator. Here the HTTP body part takes the form os a UTF-8 encoded string where the values are query-params-like formatted.
name=Matteo&password=mypassword
This gets somehow exposed on the server handler by the WebRequest "param" property, that in the inner implementation of HTTPServer seems to expect an "&" separated string of key-values:
What I would expect is to have a way to provide body data in whatever form / encoding needed, in my case a JSON form:
{"name":"Matteo", "password":"psw"}
and be able to access that data from the WebRequest in my handler, decode it and use it to serve the request.
To summarise, I assume you could say that a WebRequest.bodyData public property is what I am after here :).
Is there something I am missing here?
Thanks in advance for any clarification!
How can I remove a Header from response in grails. I have a filter which filters requests and in case response contains a specific header I want to remove it is this possible?
Thanks,
It looks like the only way to do this is to have your servlet filter wrap the response with an implementation of HttpServletResponseWrapper that filters out the header you want to remove. So you're not physically removing the header, but when the response is generated only the headers that your response wrapper returns will be included in the HTTP response.
I've not tried this, so if it does work, please let me know!