[英]JSON response error when making an API call
I am trying to get capture the JSON response from an API and I am getting the below error. 我试图从API捕获JSON响应,但出现以下错误。 I want to understand why this error is showing up. 我想了解为什么会出现此错误。
401 - Unauthorized: Access is denied due to invalid credentials. 401-未经授权:由于凭据无效,访问被拒绝。
You do not have permission to view this directory or page using the credentials that you supplied. 您无权使用您提供的凭据查看此目录或页面。
Not Authorized HTTP Error 401. The requested resource requires user authentication. 未授权HTTP错误401。请求的资源需要用户认证。
{
"membershipId": 190000,
"organizationId": 0,
"paymentFrequency": "Month",
"effectiveDate": "2016-11 30T00:00:00",
"promoPackageCode": "P56S",
"rebatePercentage": 17.861,
"rateDetails": [
{
"rateType": 0,
"rateDescription": "CurrentRate",
"rebate": "Y",
"amount": 123.45
},
{
"rateType": 1,
"rateDescription": "PromoRate",
"rebate": "Y",
"amount": 155.75
},
{
"rateType": 2,
"rateDescription": "PromoRateDiff",
"rebate": "Y",
"amount": 32.30
},
{
"rateType": 3,
"rateDescription": "NonRebateCurrentRate",
"rebate": "N",
"amount": 150.3
},
{
"rateType": 4,
"rateDescription": "NonRebatePromoRate",
"rebate": "N",
"amount": 189.65
},
{
"rateType": 5,
"rateDescription": "NonRebatePromoRateDiff",
"rebate": "N",
"amount": 39.35
}
]
};
SyntaxError: JSON.parse 语法错误:JSON.parse
I think your are not passing authentication key in header. 我认为您没有在标头中传递身份验证密钥。 The message shows , you have not sufficient right to access the api. 消息显示,您没有足够的权限访问api。
在API ajax请求中,您需要向HTTP链接添加密钥(从API站点请求密钥)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.