【发布时间】:2020-05-15 11:12:31
【问题描述】:
Q) 我想使用 python 调用 GET API,这需要时间来获得响应。 我不需要等待我只想发送请求并关闭线程的响应。请帮我解决这个问题。这种情况我该怎么办?
def call_oms(in_params, thread_ts):
url_list = {
"static": "http://ptw01am1ap001:2003/execute"
}
executionId = str(random())
# real data
order_id =in_params["order_id"]
fulfillment = in_params["fulfillment"]
# env = in_params["env"]
# mocking data
# order_id = "CX01-1043562345"
# fulfillment = "shiptohome"
env = "static"
print("Consumming API -- In_params")
print(order_id)
print(fulfillment)
url = url_list[env] + "?orderNumber=" + order_id + "&testCaseName="+fulfillment + "&executionId="+ thread_ts
print(url) - This is printing the url with the parameters we send this to message
r = requests.get(url)
print(r.status_code)
【问题讨论】:
-
我认为你应该使用 requests.post() 而不是 requests.get()
-
它实际上是一个GET API,我不能做requests.post()
标签: java python api async-await