can i get a different response from postman example - postman

let's me explain
i'm using mock server in post man for testing login post
so i set header to [x-api-key : {{postman-api-key}} //(i already got my api key from postman)
and I set Body request and response like this
my question is : If i post wrong password from body request can i set body response to show (error ,Password incorrect) form other example it's possible?
There is any To samples for me?

Related

How to read request's body in WSO2 ESB?

Hi everyone I am new using WSO2 ESB, here is the issue I made a integration project to learn but I have not been able to read the body of my request when I try I see this warning "Json Payload is empty"
enter image description here
Here is how I am trying to read the body <filter regex="[1-9]" source="json-eval($.test)">
enter image description here
And finally here is my request, I already set the header application/json
enter image description here
If anyone could help me, I would be very grateful. Thanks in advance
The request needs to be a POST to see the payload hit the ESB.
With GET it will just do a GET request without it.
Technically you can do GET with body but it's not a very common scenario.[1]
[1]https://docs.wso2.com/display/EI611/Unusual+Scenarios+for+HTTP+Methods+in+REST#UnusualScenariosforHTTPMethodsinREST-UsingGETwithaBody
That is because the GET method in wso2 does not allow the body payload. You can read in wso2 documentation:
Typically, a GET request does not contain a body, and the ESB profile does not support these types of requests. When it receives a GET request that contains a body, it drops the message body (...)
From doc: Using GET with a Body
Additional it is not good practice to do that, refer to this question: HTTP GET with request body
So you should use POST request.

Send POST json data to an url with POSTMAN not working

I have python code wrote here: https://repl.it/#AndreiCiobnic/MixedWealthyGnuassembler
I'm trying to (re)write in Postman to make a POST request to that url.
I put like:
But I got error response from that server.
How to send the data json in Postman ?

Qt GET request strange response

I'm writing a program to log into a game a get some information from the account.
After making a post request with username and password, I make a get request in the same location in order to download the needed html source.
However, doing qDebug()<<QString(reply->readAll());
prints "\u001F?\b" ,instead of the entire source code of the page.
The get reply has status code 200, and the error() function returns NetworkError(NoError).
For the post and get requests I'm using header information obtained from chrome's network tab in developer options combined with cookies obtained from previous response headers.
I'm doing a get request after the log-in post request because that's what seems to happen in the actual webpage, as displayed in developer options.
The response might be gzipped. Does unzipping happen to yield the expected result?

Correct HTTP status code when POST xml is invalid?

What HTTP status code should I return when a POST request is made to my RESTful API but the content in the POST field (let's say an XML) is invalid?
I would like to build a proper RESTful web service so I want to know.
I am now returning 405 when a HTTP method not supported by specific API is used, 200 when everything goes ok and 500 for all other errors (XML validation error etc).
Thank you.
I would respond with 400
400 Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
That's what status code 422 is for.

Problem with Posting JSON object with WSRequest

I want Play to call a webservice. The webservice accepts application/json and returns this as well. With the following code I'm trying to achieve this. (Note, the headers.put(xxx) are added later in an effort to solve the problem).
WSRequest request = WS.url(targetURL);
request.body = new Gson().toJson(user);
request.headers.put("Content-type","application/json");
request.headers.put("Accept","application/json");
request.post();
The strange thing is that my JBOSS server replies: "Cannot consume content type". If I use my 'Simple REST client' plugin in my Chrome browser, and provide the entire JSON Body GSon created and add the content-type header, I get a valid response. Is this not the way to send JSON to the server? Or am I missing some fundamental piece here?
While checking the API documentation on the WSRequest class i noticed the field mime-type
By setting it as follows JBOSS (resteasy) accepted my request succesfully.
request.mimeType = "application/json";