I'm using PAW for testing and documentation writing, everything is okay, PAW works like its needed but when I send the request and got the JSON object response, how to document it (for example if I export to swagger, this is the responses/schema/properties/description part). I can write documentation/comment for request, variables, etc but not for response which is highly needed.
Thanks (PAW 3.1.10)
Related
I have a requirement where I need to make a HTTP request to a Flask server where the payload is a question(string) and a paragraph(string). The server uses machine learning to find the answer to the question within the paragraph and return it.
Now, the paragraph can be huge, as in thousands of words. So will a GET request with a JSON payload be appropriate? or should I be using POST?
will a GET request with a JSON payload be appropriate?
No - the problem here is that the payload of a GET request has no defined semantics; you have no guarantees that intermediate components will do the right thing with your request.
For example: caches are going to assume that the payload of the request is irrelevant, so your GET request might get a response for a completely different document.
should I be using POST?
Today, you should be using POST.
Eventually, you'll probably end up using the safe-method-with-body, once the HTTP-WG figures out the semantics of the new method and adoption has taken hold.
I'm working in a Go Lang REST API repo.
I'm wanting to build an endpoint that will take in a file (as part of the form-data, so I suppose I'll use request.FormFile('my-file-key')). This endpoint should also take in a body of a JSON model (which i suppose would be decoded with something like this:
var myData model.MyModel
json.NewDecoder(request.Body).Decode(&myData)
But I'm running into a lot of issues. Is it even possible to send both a body and a file in the form-data with a http request?
If I try to send both I get errors from FormFile saying that it can't find the file of the key name (but if I send the exact same request without a body, this error doesn't happen). I guessing it's having trouble decoding the request.
What you need is a multipart request. One part can be JSON data, and the other part the file data.
If you're using a Go client to prepare the request, you need to use the mime/multipart package to create a Writer, then use CreatePart to create the JSON part, then the file part, and submit the request to the server.
On the decoding side: since the body is JSON you cannot parse it as a form. You have to use a multipart.Reader to read from the body after you parse the headers. Again, from that reader you get a Part, and read the data from that part. You'll get two parts, one for the JSON data and one for the file data.
I tried to reproduce a bunch of SOAP requests sent by an .exe file in Postman but the API end point does not send back the correct result.
I constructed a request exactly like the one captured with Wireshark, but the response is not correct.
What seems to be the problem? What am I missing?
Update:
I just tried to send these request using SoapUI instead of Postman and with SoapUI the response is a SOAP response so it seems more correct, the endpoint still doesn't send back correct result, but at least the response is a SOAP response now.
Apparently Postman messes up the SOAP request in some way.
Solution:
I created a soap service with SoapUI and used the wsdl.xml file provided by the web service
SoapUI automatically generated all operations/requests defined in the wsdl.xml
I sent these auto generated requests made by SoapUI and they worked.
So I compared these requests with the ones I was sending and realized the syntax (xml body of the request) of these auto generated requests was different than the ones described in the web service doc.
but there are still some weird things that I don't understand, like the requests I captured with Wireshark had the same xml body as in the Doc described but they were successful responses.
I am trying to post protobuf data with JMeter. I have a Sampler HTTP Request setup with the body as:
b''
This should simply be an empty protobuf object, but JMeter is actually sending some wrapped version of this:
b"b''"
I have used Content-Type to be both application/protobuf and application/octet-stream.
Is there a way to get JMeter to post EXACTLY what I give it.
I have a web-servise which listens to the JSON requests from different data sources. I want to identify data source by special parameter data-source. My question is how I can add field "data-source": "jira" to the webhook JSON body?
EDIT
For now my solution is to add to my webhook uri http://127.0.0.1:8080/DC data source parameter like this: http://127.0.0.1:8080/DC?data-source=jira, then check data source type and if it is equal to jira send request JSON body to method jiraJsonParser().
But I'm not sure if it is the best solution, isn't it?
I had a similar need, and solved the problem by creating a REST API with flask that acts as an aggregator/translator to accept requests from multiple tools, format the request as needed, and pass it on to it's intended target. For example, I have a Jira 'build request' ticket that sends a POST request via webhook to my API upon ticket creation. The API accepts the request, formats it as needed, fwd's the request on to Jenkins to run a build. As each part of the build runs, Jenkins sends requests back to the API, which get formatted as needed, and the original Jira ticket gets updated with the details/status of the build.
Here's a good article on building a REST API with flask - http://blog.luisrei.com/articles/flaskrest.html