如何使用Postman请求特定网址的GET方法?

e37o9pze  于 2023-01-26  发布在  Postman
关注(0)|答案(2)|浏览(163)

我想用 Postman 得到一些结果。
预期结果:

{
    "status": "200",
    "message": "success",
    "results": {
        "count": "6816",
        "data": [
            {
                "timestamp": "2022-07-17T10:47:03Z",
                "sender": "0x2F664960a7FBdaDA8e133DbAF1Bfc27DCCBADBfb",
                "receiver": "0xA68A135Ccd37E720000fC30CFcc453b15F8040df",
                "value": "0",
                "status": "1",
                "message": "",
                "transaction_hash": "0x1a03528eecf165678d7fbcb9ceeee45a98b02f10a5ce30236ef29ee5b3747c84",
                "block_number": "2472",
                "contract_address": null,
                "trace_address": [
                    "0",
                    "1",
                    "1"
                ],
                "trace_type": "staticcall",
                "sub_traces": null,
                "transaction_index": "0",
                "gas_used": "2715",
                "gas_limit": "29039032",
                "external_receiver": "0",
                "input": "0x0d2020dd476f7665726e616e6365436f6e74726163740000000000000000000000000000"
            },
            ...
        ]
    }
}

例如,当我请求GET方法时,
API文档:www.example.comhttps://docs.wemix.com/v/en/dapp-developer/api-reference/account-apis#get-internal-transactions-by-address-and-get-internal-transactions-by-transaction-hash
获取https://explorerapi.test.wemix.com/v1/accounts/0xA68A135Ccd37E720000fC30CFcc453b15F8040df/internal-transactions
API密钥:1ba5e446edf1997f67b51bf9e60b3fbba6f1bf84301115292805d7e24f43539响应数据
我使用Postman请求使用"api-key"的GET方法
但我的回答是

{
    "status": "401",
    "message": "Unauthorized"
}

如何修复它以获得正确的响应?或者,有没有用Python调用API的好方法?

bvjveswy

bvjveswy1#

Headers选项卡上,需要添加一个值中包含API键1ba5e446edf1997f67b51bf9e60b3fbba6fa1bf84301115292805d7e24f43539的键api-key

4nkexdtk

4nkexdtk2#

除了Khalil的答案之外,在python中也可以这样做:

import requests

headers = {'api-key': '1ba5e446edf1997f67b51bf9e60b3fbba6fa1bf84301115292805d7e24f43539'}
response = requests.get('https://explorerapi.test.wemix.com/v1/accounts/0xA68A135Ccd37E720000fC30CFcc453b15F8040df/internal-transactions', headers=headers)
print(response)

〈Response [200]〉,它将为您提供所需的数据。
所提供的API密钥末尾为RESPONSE DATA,这是无效的API密钥。

相关问题