你能帮我解决这个问题吗?我正在努力使用Requests库获取数据。
import requests
payload = {'company':'USA', 'employeeid':'EMP1235'};
headers= {
"Content-Type": 'application/json',
'Access-Control-Allow-Origin': '*',
'Authorization': "Bearer MyToken Pasted here",
}
response = requests.get(
'https://MyCompanyPath/getEmployeeDetails',
params=payload ,
headers= headers,
)
print(response.json())
# or
print(response.text)
输出
请注意,状态显示200
为成功。以下是响应内容,但我没有看到任何数据。
{'Parameters': [{'Name': 'company', 'Type': 'String'},
{'Name': 'employeeId', 'Type': 'String'}],
'Return': {'Name': 'return', 'Type': 'String'}}
但是在Postman中,它显示了完整的数据输出,如下所示:
"[{\"AccountNumber\":\"\",\"Address\":[{\"Address\":\"123 Coffee Street\\nSuite 300\\nRedmond, WA 98052 \\nUSA\",\"Description\":\"Contoso Entertainment System USA\",\"Primary\":\"No\",\"Purpose\":\"Business\"},{\"Address\":\"8367 Oak Ave\\nBlack Diamond, WA 98122 \\nUSA\",\"Description\":\"Home address\",\"Primary\":\"Yes\",\"Purpose\":\"Home\"}],\"RHRMEmplCategory\":\"\",\"AllowancesInformation\":[],\"AnniversaryDate\":\"/Date(-2208988800000)/\",\"ArabicName\":\"\",\"BankId\":\"\",\"BankLoan\":\"No\",\"BankName\":\"\",\"BirthDate\":\"/Date(-2208988800000)/\",\"ContactInformation\":[{\"ContactDetails\":\"theresa@contoso.com\",\"Description\":\"Work\",\"Extension\":\"\",\"Primary\":\"Yes\",\"Type\":\"Email\"},{\"ContactDetails\":\"425-555-5108\",\"Description\":\"Work\",\"Extension\":\"5108\",\"Primary\":\"Yes\",\"Type\":\"Phone\"}],\"ContractInformation\":[],\"Description\":\"\",\"EmplGender\":\"\",\"EmplMaritalStatus\":\"None\",\"EmployeeJobDetails\":[{\"Description\":\"Treasurer\",\"DescriptionText\":\"\",\"Function\":\"0200\",\"JobName\":\"Treasurer\",\"JobType\":\"Managers\"}],\"EmployeeJobResponsibility\":[{\"areaOfResponsibility\":\"Acctg & Finance\",\"Description\":\"Accounting and finance\",\"note\":\"\"}],\"EmployeeJobTask\":[{\"Description\":\"Financials/Accounting\",\"JobTask\":\"Accounting\",\"note\":\"\"}],\"EmployeeMedicalDetails\":[{\"fromDate\":\"/Date(-2208988800000)/\",\"InsuranceCompanyName\":\"\",\"InsuranceLevel\":\"\",\"InsuranceNumber\":\"\",\"InsuranceType\":\"None\",\"RelativeMedicalDetails\":[],\"toDate\":\"/Date(-2208988800000)/\"}],\"EmployoeeDocumentDetails\":[],\"HcmWorkerName\":\"rrrJayne\",\"IBAN\":\"\",\"NameAlias\":\"Theresa Jayne\",\"Nationality\":\"\",\"NSGEmplLocationId\":\"\",\"PaymentType\":\"\",\"RelativeInformation\":[],\"Religion\":\"\",\"StartDate\":\"/Date(-2208988800000)/\"}]"
请注意,JSON 作为字符串从 3rd 方应用程序返回。