Python 中的 REST API 调用返回错误代码 500011

问题描述

当我在 Postman 中调用这个 REST API 时,它会返回一个访问令牌

enter image description here

当我使用此代码在 Python 中尝试时,我得到 this error

import os
import requests
import json
import jmespath
import pandas as pd

from pprint import pprint
from pyapacheatlas.auth import ServicePrincipalAuthentication
from pyapacheatlas.core import PurviewClient,AtlasEntity,AtlasProcess,TypeCategory
from pyapacheatlas.core.typedef import *

from pyspark.sql import *
from pyspark.sql.functions import *
from pyspark.sql.types import *

tenant_id = "tenant-id"
client_id = "client-id"
client_secret = "client-secret"
data_catalog_name = "catalog-name"



url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/token"
payload= f'grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}&resource={resource_url}'
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}


response = requests.request("POST",url,headers=headers,data=payload)
access_token = json.loads(response.text) #['access_token']

print(access_token)

任何建议我做错了什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...