简体   繁体   English

使用Python执行SoapUI API调用

[英]Performing SoapUI API Calls with Python

I am trying to call a POST API that would schedule a recording for a TV channel. 我正在尝试调用POST API,该API可以安排电视频道的录制。 The call works on SoapUI, but I can't seem to replicate the success in python (I can check whether it succeeds or not by checking my TV if a recording is scheduled). 该调用在SoapUI上有效,但我似乎无法在python中复制成功(我可以通过检查电视是否安排了录制来检查它是否成功)。 Here is the call in SoapUI: 1 2 3 这是SoapUI中的呼叫: 1 2 3

Here is the call in Python (using pydev): 这是Python(使用pydev)中的调用:

print("Record")  
url1 = "http://10.10.120.48:8080/api/CreateRecordSchedule"
{
    "type": "SERIES_PROGRAM",
    "matchingID": "SH00000000131221",
    "channelID": 11,
    "padIn": 0,
    "padOut": 0,
    "persistedRecordings": 5,
     "hd": False,
    "rerun": True
}
rsp = s.post(url1)

print (rsp.status_code)

Other api calls with the same server work fine, so I was wondering what I am doing wrong. 使用同一服务器的其他api调用工作正常,所以我想知道自己在做什么错。 Thank you! 谢谢!

You're including the data payload as part of your URL. 您会将数据有效负载作为URL的一部分。 Is that what you intended? 那是你想要的吗?

If you're just POST ing a JSON payload, the following should do the job: 如果你只是POST荷兰国际集团一个JSON有效载荷,下面应该做的工作:

import requests

url1 = 'http://10.10.120.48:8080/api/CreateRecordSchedule'
payload = '''{
    "type": "SERIES_PROGRAM",
    "matchingID": "SH00000000131221",
    "channelID": 11,
    "padIn": 0,
    "padOut": 0,
    "persistedRecordings": 5,
     "hd": False,
    "rerun": True
}'''
rsp = requests.post(url1, data=payload)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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