Python URL查询字符串变量传递不起作用

时间:2018-04-05 20:06:16

标签: python-2.7 apigee

我使用APIGEE管理API调用获取数据。当我将查询字符串保持为静态值时,我的代码可以工作,但是一旦我使用日期变量它就失败了。如果有人能帮助我实现它将是非常有帮助的。

import base64
import json 
import sys
import time
import urllib
import easygui
import requests
import easygui

apigeeurl = raw_input("Enter the IP of the Management Server: ")
which_api = raw_input("Do you want traffic details for apps or apis: ") 
which_env = raw_input("Which Environment from Organization aig: ")
start_date = raw_input("What is the start date as mm/dd/yyyy: ")
end_date = raw_input("What is the end date as mm/dd/yyyy: ")
pstmnauth = raw_input("Enter your auhorization: ")

url = "http://"+apigeeurl+":8080/v1/organizations/aig/environments/" + which_env + "/stats/"+which_api

querystring = '{"select":"sum(message_count)","timeRange":"03/20/2018 00:00~03/25/2018 00:00","timeUnit":"day"}'

# querystring = {"select":"sum(message_count)","timeRange":'"'+start_date+' 00:00~'+end_date+' 00:00"',"timeUnit":"day"}

headers = {
    'authorization': "Basic "+pstmnauth,
}

response = requests.request("GET", url, headers=headers, params=querystring)

0 个答案:

没有答案