My script is, call api post "https://demotestapp-backend-dev.azurewebsites.net/api/students" with headers "Content-Type:application/json" and "Accept:application/json" and body "{\"firstName\":\"James\",\"lastName\":\"Warner\",\"isActive\":\"true\",\"gender\":\"1\"}" and then check that http code is 200
Can anyone give a sugggestion to solve this please?
HTTP 400 means there is something wrong in your request. Ideally, the API should give you more details in the response - does the response have a body? Also, is there some documentation you can refer to?
I donât have access to the APIâs documentation so I can just guess. What looks weird in your request body is that youâre sending "true" and "1" both as string datatype. I would expect true to be boolean and 1 to be an integer. So just try to leave out those quotation marks and see what will happen.
I would say that it is related to your body. The json does not seem to be correctly formated but I am not an expert in testrigor. As far as I can tell other used the same and it worked
call api post "http://dummy.restapiexample.com/api/v1/create" with headers "Content-Type:application/json" and "Accept:application/json" and body "{\"name\":\"James\",\"salary\":\"123\",\"age\":\"32\"}" and get "$.data.name" and save it as "createdName" and then check that http code is 200
Thatâs why I put quotation marks.I think that itâs a syntax pattern of testrigor.
Itâs not a syntax pattern of testrigor, itâs a syntax pattern of a JSON. Strings have quotes, other data types donât. Your example includes strings only.