简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM