I have created a POST request to generate a token for myself. Next, I wrote the code for assertion using pm.test() and its working. Following that, I sent another request via pm.sendRequest(). As a result of this request, I am receiving a response but not able to assert it.
I should be able to assert a response if I am receiving one
. Any and all help is appreciated!
Related
I am trying to use two api call (Post & put call) in one scenario in karate framework. But I am not able to validate 2nd Api call response. when i tried to do like response.id , it passing 1 st api call response.
Is there any solution for it?
In your feature file, you wrote your print response in When instead of writing it after Then. Which means it is showing the previous response only. As per documentation response gets overridden after making a new http request.
Following,
...
When method put
And print 'jokerresult-->',response.joker_result
Then status 201
Should be like,
...
When method put
Then status 201
And print 'jokerresult-->',response.joker_result
let me know if it worked for you or not.
When I develop POST api, I used POSTMAN I create following request
But it seems send empty request to servers.
When I check server, the following error was displayed
Error: data and salt arguments required
It means empty body was send via POSTMAN
On the other hand ,When I tried
curl --data "loginId=hikaru&password=test" http://localhost:3000/user
following error was occured but some data was send and reached
ER_NO_DEFAULT_FOR_FIELD: Field 'firstName' doesn't have a default value
So what is the difference between POSTMAN and command ?
What is the wrong point of postman
I'd like to fix it.
If someone has opinion,please let me know.
Thanks
I've been trying to send a GET request to CDiscount's GetProducts API by using the Json format provided by the documentation and have been met with an Error: read ECONNRESET.
I use the Raw (set to JSON) window in Body to send this request.
Any ideas on how to solve this?
GET request doesn't send Body content. Only for POST and PUT send body.
I have the following rest request that works:
And the following one that doesn't work:
And here is the the response from the bad message:
The bad response was run through PowerShell but it shouldn't matter as I can see everything that is getting sent in Fiddler.
Can anyone spot what I have done wrong in the bad request?
I am implementing a REST API and i have a set_ftp_credentials request
for example
POST api.domain.com/object/set_ftp_credentials
This request checks that the ftp credentials are good by trying to connect.
We had a discussion here whether we should return a HTTP response 200 and in the content
return the the request have failed and the reason.
Or we should return some other HTTP response code (40* response code).
What is considered the right way of doing this ?
And if not 200 then what do you think is the right response code ?
I believe that 200 is an OK response and should only be sent when the request was successfully satisfied.
One approach would be to answer the following questions for yourself:
What HTTP methods are you supporting?
What is the expected behavior of each HTTP method?
For each supported HTTP method, What are the possible classes of failures that can result if something goes wrong?
Now, return your expected response pay load with a 200 HTTP response code. Return client side error (400 class) or server side error (500 class) for the failures.
You might want to consider the following:
Return error codes that are specific to your application and map them to HTTP error codes
Have separate data contracts (assuming JSON format or XML schema) defined for successful response and error responses