I ran my codes below but get a response of “Error: 401 Status Code: 401; Unauthorized”
def Pods_Assets(token):
url = “https://api.aqmeshdata.net/api/Pods/Assets_V1”
# Implement Bearer authentication
class BearerAuth(requests.auth.AuthBase):
def __init__(self, bearer_token):
self.token = bearer_token
def __call__(self, r):
r.headers['Authorization'] = 'Bearer ' + self.token
return r
api_token = {"authorization": token}
auth = BearerAuth(api_token["authorization"])
headers = {"Accept": "application/json"}
# Make the GET request
response = requests.get(url, auth=auth, headers=headers)
if response.status_code == 200:
json_response = response.json()
data: object = json_response
print('Successfully retrieve data: [site_details]')
print('Response time:', response.elapsed.total_seconds(), 'seconds', 'n')
return data
else:
print("Error:", response.status_code, response.text)
I tried to use POST Requests Online tools to figure out the website is still working properly. The raw is listed below.
GET /api/Pods/Assets_V1 HTTP/1.1
Authorization: Bearer xxxxx
Host: api.aqmeshdata.net
Accept: application/json
The supplier provided me an example file. The content is listed below.
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{SampleAuthToken}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/xml",
"disabled": true
},
{
"key": "Accept",
"value": "application/json",
"disabled": true
}
],
"url": {
"raw": "https://api.aqmeshdata.net/api/Pods/Assets",
"protocol": "https",
"host": [
"api",
"aqmeshdata",
"net"
],
"path": [
"api",
"Pods",
"Assets"
]
}
},
New contributor
Han Xiao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.