view raw
Radit Panjapiyakul Radit Panjapiyakul - 6 months ago 74
Python Question

How can I send post request with null datas JSON in Robot Framework?

I'm using Robot framework's RequestsKeywords to test a service. And there is a test case to send null datas to the service.
I want to send something with nulls like this as a request body:

id: "some-id",
name: null,
address: null,
tell_no: null

As in the document of Post Request, the data needs to be send a dictionary of key-value pairs.

But how can I set my key-value pair with this null? I tried to do the $None as below:

${request_data}= Create Dictionary
Set To Dictionary ${request_data} name=$None

But it just becomes a '$None' string instead in the dictionary.


Your syntax for none is incorrect, it should be ${None}, if that doesn't work I would try ${EMPTY}.

Finally if both of the above aren't looking like the right answer, I would create an empty JSON file in your test data and simply point to its file location as the data.

Let us know which method works for you.