I tried to send the HTTP POST request, but I am always getting 500 error.
I copied the request body from browser when I manually trigger the same request, and my body json file looks like this:
{
“id”: “123”,
“name”: “NewName”,
“deactivated”: false,
“group”: null
}
I noticed in my HTTP GET Keyword that null is displayed as None for example in my log.
So, I tried changing false to False, null to None in my json file.
Still getting 500.
Is there anything that I am missing, because my Browser Library HTTP GET Keyword works fine.
You cannot reference a file as payload (body or json). What your code is doing now, is sending the string “body.json” as the body of the request.
You’ll need to read the file content into a variable, easiest is to use the json module for this (or a RF library). Reading a json file like this gets you a dictionary, which you can pass to the json parameter of a HTTP request.
Get File will get you the file content as a string. You’ll need to either turn it into JSON (encode / serialize) to pass it to the body parameter or first convert the string to a (Python) dict and pass that to the json parameter.
If you load the file content as json (using e.g. the JSONLibrary or json module in Python) you can pass that directly to the json parameter.