I am trying to test an HTTPS API with Robot Framework and cannot get a post request to suceed. It involves HTTPS, a security certification, json data. Based on the tests (https://github.com/bulkan/robotframework-requests/blob/master/tests/testcase.txt), it should be simple. But no combination of session create verify, post request verify, list or dictionary header combos seems to satisfy the RF-RequestLibrary to spit back results.
Debug from RF log shows: "post response: {"error":{"code":401,"message":"Missing Basic Authorization Header"}}" with all combos. What am I missing?
Robot Framework API Post Test1
&{data}= Create Dictionary any....@yourcorp.com
Create Session mysession https://<our-secret-url>
&{auth}= Create Dictionary authorization "Basic <secret>" verify=${CERTDIR}/cacert.pem
${resp}= Post Request mysession / auth=${auth} params=${data}
Should Be Equal As Strings ${resp.status_code} 200
Robot Framework API Post Test2
&{data}= Create Dictionary any....@yourcorp.com
Create Session mysession https://<our-secret-url> verify=${CERTDIR}/cacert.pem
&{auth}= Create Dictionary authorization "Basic <secret>"
${resp}= Post Request mysession / auth=${auth} params=${data}
Should Be Equal As Strings ${resp.status_code} 200
Robot Framework API Post Test3
&{data}= Create Dictionary any....@yourcorp.com
Create Session mysession https://<our-secret-url> verify=${CERTDIR}/cacert.pem
${auth}= Create List authorization "Basic <secret>"
${resp}= Post Request mysession / auth=${auth} params=${data}
Should Be Equal As Strings ${resp.status_code} 200
...etc. etc....
Frustratingly, Postman, cURL and the Requests library in Python have absolutely no problem:
===================== Request Library return results !
import requests
url = "https://<our-secret-url>"
payload = "{\"email\":\"any....@yourcorp.com\"}"
headers = {
'content-type': "application/json",
'authorization': "Basic <secret>",
'cache-control': "no-cache",
'postman-token': "<secret>"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
===================== cURL return results!
curl -X POST \
https://<our-secret-url> \
-H 'authorization: Basic <secret>' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: <secret>' \
-d '{"email":"any....@ourcorp.com "}'
Help before I'm forced to abandon Robot Framework!
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
| &{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded ${resp}= Post Request httpbin /post data=${data} headers=${headers} | |