Radit Panjapiyakul Radit Panjapiyakul - 1 year ago 241
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:

data={
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.
https://bulkan.github.io/robotframework-requests/

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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download