机器人框架-API呼叫

时间:2016-02-17 09:50:34

标签: robotframework

我有运行WGET的python代码来运行API(Get \ Post,ETC)

我想对ROBOT做同样的事情,但可能会遇到语法问题。

运行api的python代码:

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"]

我想张贴json:{" type":" IDU"," serial_number":" 00000000601C7898"}' 我想使用标题:auth-token:abcde1111& Content-Type:application / json

我在Windows上使用骑行并试图使用来自"请求" LIB

请参阅随附的屏幕截图描述了我的所作所为[Image with Ride screenshot]

1 个答案:

答案 0 :(得分:1)

希望这个例子可以帮到你:

${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}