1
votes

I have python code that run WGET to run API (Get\Post,ETC)

I want to do the same with ROBOT but having problem with syntax probably.

My python code to run api:

APIWGET = [WGETInstallationFolder,"--post-data="+PostFile,"--output-file="+TempReadWritePath + 'TempReadWriteFile' + TimeNow + '.txt',"--wait=2","--content-on-error", "--header="+HeaderTokenAdmin1+TokenToVar,"--header="+Header, "--output-document="+TempReadWritePath + 'TempReadWriteFile' + TimeNow + '.txt',"--timeout=3","--tries=3", "--save-headers", "http://" + BEIP +":8080/lms/v1/components"]

I want to Post json :{ "type": "IDU", "serial_number": "00000000601C7898"}' I want to use headers : auth-token: abcde1111 & Content-Type: application/json

I'm using ride on windows and have tried to use post keyword from "request" lib

Please see attached screen shot describes what I did[Image with Ride screenshot]

1
Didn't manage to pass the scrennshot - ohad

1 Answers

1
votes

Hope this example can help you:

${auth}    Create List    <username>    <password>
Create Session    my_session    <URL>    auth=${auth}
${headers}    Create Dictionary    Accept    application/json    Content-Type    application/json
${resp}    POST    my_session    <your rest api>    data=<JSON DATA>    headers=${headers}