如何用我的输入d调用API URI

2024-10-03 09:14:27 发布

您现在位置:Python中文网/ 问答频道 /正文

为了进行地理编码,我尝试从pitney bowes获得客户信息API,他们给出了以下详细信息。在

给予:

POST https://api.pitneybowes.com/identify/identifyaddress/v1/rest/validatemailingaddress/results.json HTTP/1.1

    Content-Type: application/json
    Authorization: Bearer {YOUR ACCESS TOKEN}
    Host: api.pitneybowes.com
    {
      "options": {
        "OutputCasing": "M"
      },
      "Input": {
        "Row": [
          {
            "AddressLine1": "",
            "AddressLine2": "",
            "City": "",
            "Country": "",
            "StateProvince": "",
            "PostalCode": "",
            "FirmName": ""
          }
        ]
      }
    }

我的程序收到了405的回复。{1>为什么发送请求?在

我的计划是:

^{pr2}$

Tags: httpscomapi信息json编码客户详细信息
1条回答
网友
1楼 · 发布于 2024-10-03 09:14:27

identifyAddressAPI标准化和验证地址,您应该使用Geocode API进行地理编码。在

下面是正确的python代码来调用Identify Address API,希望这有帮助:

import requests
url = 'https://api.pitneybowes.com/identify/identifyaddress/v1/rest/validatemailingaddress/results.json'
data = '''{
"options": {
    "OutputCasing": "M"
    },
"Input":
    {
    "Row": [
        {
            "AddressLine1": "4750 Walnut St",
            "AddressLine2": "",
            "City": "Boulder",
            "Country": "USA",
            "StateProvince": "CO",
            "PostalCode": "80301",
            "FirmName": "Pitney Bowes Software"
            }
        ]
     }
    }'''
headers={'Content-Type': 'application/json','Authorization': 'Bearer YImXVIfpDOsadpv8SCohGAC0ALcO'}
response = requests.post( url, data=data, headers=headers)
print response.text

相关问题 更多 >