当代码部署到Azure函数应用程序时,无法从第三方API获取HTTP响应,在调试模式下工作正常

发布于 2025-02-11 17:31:50 字数 8597 浏览 2 评论 0原文

我已经创建了一个Azure HTTP触发器(也使用Timer Trigger尝试),它将以必要的参数作为内容标头调用第三方API。在VS代码(调试模式)中本地,它工作正常。我得到了期望的响应(如果我们调用令牌终点,如果我们通过传递令牌调用另一个终点,请获得令牌)。即使有了邮递员,我也得到正确的回应。

但是,当我将此函数部署到Azure函数应用程序时,它不会从两个端点获得响应。 (无论是从代币一个,还是我经过了从邮递员复制到第二个端点的硬编码的令牌)。

在日志中,我可以看到函数被调用,当我记录响应时,我会得到一个大的HTML文本(不知道那是什么) 第三方API是否有可能阻止或限制Azure函数的呼叫(尽管如果我们通过适当的值,它在本地工作或与Postman一起工​​作) 尝试了一切,但可以找到确切的问题。我已经验证了我将正确的值作为grant_type,client_id,client_secret,用户名,密码,范围)

粘贴在下面的示例代码:

private async Task<Token> GetToken()
  {
    try{
     HttpContent content = new FormUrlEncodedContent(new Dictionary<string, string>
    {
        {"grant_type", Environment.GetEnvironmentVariable("test-grant-type")},
        {"username", Environment.GetEnvironmentVariable("test-username")},
        {"password", Environment.GetEnvironmentVariable("test-password")},
        {"client_id", Environment.GetEnvironmentVariable("test-client-id")},
        {"client_secret", Environment.GetEnvironmentVariable("test-client-secret")},
        {"scope", Environment.GetEnvironmentVariable("test-scope")}
    });
    
    HttpClient client = new HttpClient();
    
    string tokenEndPoint = Environment.GetEnvironmentVariable("test-tokenApiEndPoint");
    
    //calling API
    HttpResponseMessage messageResult = await client.PostAsync(tokenEndPoint, content);        

                    
    _logger.LogInformation($"Log Info:  GetToken method: httpResponseMsg: {messageResult}");
    
    string apiResponse = messageResult.Content.ReadAsStringAsync().Result;

    _logger.LogInformation($"Log Info:  GetToken method: apiResponse: {apiResponse}");
    
    Token resTokenModel = JsonConvert.DeserializeObject<Token>(apiResponse);
    }
    catch (System.Exception ex)
    {
        _logger.LogError($"Exception : GetToken Method: Exception: {ex.Message}");
        throw new Exception(ex.Message);
    }
return resTokenModel;
}

log html响应示例(因为它很大而不完整),log1:log1:

2022-06-29T08:30:05.490 [Information] Log Info:  GetToken method: httpResponseMsg: StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:{Cache-Control: no-store, no-cachePragma: no-cacheStrict-Transport-Security: max-age=31536000; includeSubDomainsX-Content-Type-Options: nosniffX-Frame-Options: DENYLink: <https://aadcdn.msauth.net>; rel=preconnect; crossoriginLink: <https://aadcdn.msauth.net>; rel=dns-prefetchLink: <https://aadcdn.msftauth.net>; rel=dns-prefetchX-DNS-Prefetch-Control: onP3P: CP="DSP CUR OTPi IND OTRi ONL FIN"x-ms-request-id: 18670f19-3bec-4556-9b66-2c3760855300x-ms-ests-server: 2.1.13006.6 - WEULR1 ProdSlicesX-XSS-Protection: 0Set-Cookie: buid=0.AQIANaKxxxx_PBbRZsxxxx_PzErkPdDcCAdAA.xxxx--DLA3VO7QrddgJg7WevrDRjJU0T4KWPoylW2bC-ExpJHweIFWSInAdxjVwFITAQNF_FKbJPKHxxxxxp9ivEPYDacemz4wUo_sc04zyJbXjfz-2bVvxUz-AgAA; expires=Thu, 28-Jul-2022 08:30:05 GMT; path=/; secure; HttpOnly; SameSite=NoneSet-Cookie: fpc=AsZ-7OJNXMJAsZa7WVUJsyzxSauWAQAAAAyzTNoOAAAA; expires=Thu, 29-Jul-2022 08:30:05 GMT; path=/; secure; HttpOnly; SameSite=NoneSet-Cookie: esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrvlcjjHs6JSFKoM9RHgIe1sGicQYOARxxxxwtTCtFHUZ7DawxrkQC4x3uxxkXSFkTTUgthZA1MEqk-Pmv2mzfkL9xBHg1V-LSzxeaWxtB38SA--OJKRBbdBVRR0D80RGqwGWTn5bm4XeaaWFCt5SYYet_q1fuHwxUMe7OXIuQgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=NoneSet-Cookie: x-ms-gateway-slice=estsfd; path=/; secure; httponlySet-Cookie: stsservicecookie=estsfd; path=/; secure; httponlyDate: Tue, 28 Jun 2022 08:30:04 GMTContent-Type: text/html; charset=utf-8Expires: -1Content-Length: 195652}

从html下方,html,html,html,我只能理解“登录到您的帐户”,但是在哪里签名,Log2:

2022-06-28T08:30:05.492 [Information] Log Info: Synergi Repo: GetToken method: apiResponse:<!-- Copyright (C) Microsoft Corporation. All rights reserved. --><!DOCTYPE html><html dir="ltr" class="" lang="en"><head><title>Sign in to your account</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Expires" content="-1"><link rel="preconnect" href="https://aadcdn.msauth.net" crossorigin><meta http-equiv="x-dns-prefetch-control" content="on"><link rel="dns-prefetch" href="//aadcdn.msauth.net"><link rel="dns-prefetch" href="//aadcdn.msftauth.net"><meta name="PageID" content="ConvergedSignIn" /><meta name="SiteID" content="" /><meta name="ReqLC" content="1033" /><meta name="LocLC" content="en-US" /><meta name="referrer" content="origin" /><meta name="format-detection" content="telephone=no" /><noscript><meta http-equiv="Refresh" content="0; URL=https://login.microsoftonline.com/jsdisabled" /></noscript><meta name="robots" content="none" /><script type="text/javascript">//<![CDATA[$Config={"fShowPersistentCookiesWarning":false,"urlMsaSignUp":"https://login.live.com/oauth20_authorize.srf?response_type=code\u0026client_id=5xxx2-085c-xxxx-bf88-xxxxx8\u0026scope=openid+profile+email+offline_access\u0026response_mode=form_post\u0026redirect_uri=https%3a%2f%2flogin.microsoftonline.com%2fcommon%2ffederation%2foauth2msa\u0026state=rQQIxxxxxxFM4lbVARUISEBAuDmwnlYp99Z8dGDEFtIWogJQGEUCQ4n-_SE845sZ2UgBj5GZkYChISYycEC3QBJIREp0wIMSPBABJbO-KUFYnlLe99f-87Wxxxxkk1A8g9i0b-pawoLCQ6buGcLDlxEf2H_549xxxxvH95ugLnroRzxCot6m-DEWpr2E0_Xk7HicVcOaIUPhlJF8XSvvwZgAsAPADbzJYdaFAufQMQtA2LmBpASIaAgriAkEAjR6tf8fLM2TNfM6YhieZtvFB7ka_3-ahzdGrdTmnLvjlZXIxrK4FJ0k6sWT-Ox5qlhGJa1enI-iYRPNU_QMOFlrRnLrlQ0bNH1y3Goedpfux2982_DHb2puAy4SmU67ugsUoqztKOnUxxxxx4PMkZs0Sp1GIaYZy_EJnGgbwgTWowz5mAfE-FmyDZPEhmpPYiDGEKE2dCx7QzCmAt9GhjQtlwR2Dwj84V2d2FJBU2xl3mVxrS38LJQsijF1LQI9G1uQlwNCHSRS6AjmDBIpuX6xnahGPW5ksGXApjMgN0Z8Hw26_H4fPfYz1NXlp6IsnPjXju3PasnA0MuXsNdtFLt9thyO0zZsoqvxiuN9bONOg4vLEbDxsUzdnVQO4089KgIfhfBw325rbn_1P7iAHh3MLd7aOfbqzf3nz7-de4P0\u0026estsfed=1\u0026uaid=71c115c676664cc9bad0639fd6e7c4bf\u0026signup=1\u0026lw=1\u0026fl=easi2\u0026fci=7e7dac8e-5abd-4b36-b3f3-f312b90f7437","urlMsaLogout":"https://login.live.com/logout.srf?iframed_by=https%3a%2f%2flogin.microsoftonline.com","urlOtherIdpForget":"https://login.live.com/forgetme.srf?iframed_by=https%3a%2f%2flogin.microsoftonline.com","showCantAccessAccountLink":true,"urlGitHubFed":"https://login.live.com/oauth20_authorize.srf?response_type=code\u0026client_id=xxx-085c-xx-bf88-xxx\u0026scope=openid+profile+email+offline_access\u0026response_mode=form_post\u0026redirect_uri=https%3a%2f%2flogin.microsoftonline.com%2fcommon%2ffederation%2foauth2msa\u0026state=rQQIAxxxVE9bNNAxxxISEBAuDmwnlYp99Z8dGDEFtIWogJQGEUCQ4n-_SE845sZ2UgBj5GZkYChISYycEC3QBJIREp0wIMSPBABJbO-KUFYnlLe99f-87WUAV5JUc7gSUVTkxxxx-pawoLCQ6buGcLDlxEf2H_549P1AjD41tibs2efvH95ugLnroRzxCot6m-DEWpr2E0_Xk7HicVcOaIUPhlJF8XSvvxxxbzJYdaFAxxxxxiAkEAjR6tf8fLM2TNfM6YhieZtvFB7ka_3-ahzdGrdTmnLvxxxrK4FJ0k6sWT-Ox5qlhGJa1enI-iYRPNU_QMOFlrRnLrlQ0bNH1y3Goedpfux2982_DHb2puAy4SmU67ugsUoqztKOnUymtrLWyW56kmRshQ14PMkZs0Sp1GIaYZy_EJnGgbwgTWowz5mAfE-FmyDZPEhmpPYiDGEKE2dCx7QzCmAt9GhjQtlwR2xxxxd2FJBU2xl3mVxrS38LJQsijF1LQI9G1uQlwNCHSRS6AjmDBIpxxxxsGXApjMxxx26_H4fPfYz1NXlp6IsnPjXju3PasnA0MuXsNdxxxvxiuN9bONOg4vLEbDxsUzdnVQO4089KgIfhfBw325rbn_1P7iAHh3MLd7aOfbqzf3nz7-de4P0\u0026estsfed=1\u0026uaid=71c115c676664cc9bad0639fd6e7c4bf\u0026fci=7e7dxxxx-b3f3-f312b90f7437\u0026idp_hint=github.com","fShowSignInWithGitHubOnlyOnCredPicker":true,"fEnableShowResendCode":true,"iShowResendCodeDelay":90000,"sSMSCtryPhoneData":"AF~Afghanistan~93!!!AX~Åland Islands~358!!!AL~Albania~355!!!Islands~358!!!AL~Albania~355!!!
---------
-- and so here is large html content as above ---
-------------------------------------------------------------------------------------------------- Exception log: This is because in code we are parsing response (so below issue is because it tried to parse response html) - so this does not seems to be useful
2022-06-29T15:18:14.657 [Error] Exception : GetToken Method: Exception: Unexpected character encountered while parsing value: '<'. Path '', line 0, position 0.
2022-06-29T15:18:14.710 [Error] Exception :  Method: Exception: One or more errors occurred. (Unexpected character encountered while parsing value: '<'. Path '', line 0, position 0.)

如果有人遇到了类似的问题,或者可以想到可能是原因,尽管很难找到代码,

谢谢

I have created an azure http trigger (also tried with timer trigger) function and it is calling an third party API with necessary params as content header. Locally in VS Code (debug mode), it's working fine. I am getting desired response (getting token if we call token end point as well as proper response if we call another end point by passing token). Even with postman I am getting correct response.

But when I deployed this function to azure function app, it's not getting response from both endpoint. (either from token one or if I pass hardcoded token copied from postman to second endpoint).

In logs, I can see function being called and when I am logging response I am getting a large html text(don't know what is that)
Is it possible that third party API is blocking or restricting calls from azure function(though it's working locally or with postman if we pass proper values)
Tried everything but can' find out the exact issue. I have verified I am passing correct values as grant_type, client_Id, client_secret, username, password, scope)

Have pasted below sample piece of code:

private async Task<Token> GetToken()
  {
    try{
     HttpContent content = new FormUrlEncodedContent(new Dictionary<string, string>
    {
        {"grant_type", Environment.GetEnvironmentVariable("test-grant-type")},
        {"username", Environment.GetEnvironmentVariable("test-username")},
        {"password", Environment.GetEnvironmentVariable("test-password")},
        {"client_id", Environment.GetEnvironmentVariable("test-client-id")},
        {"client_secret", Environment.GetEnvironmentVariable("test-client-secret")},
        {"scope", Environment.GetEnvironmentVariable("test-scope")}
    });
    
    HttpClient client = new HttpClient();
    
    string tokenEndPoint = Environment.GetEnvironmentVariable("test-tokenApiEndPoint");
    
    //calling API
    HttpResponseMessage messageResult = await client.PostAsync(tokenEndPoint, content);        

                    
    _logger.LogInformation(
quot;Log Info:  GetToken method: httpResponseMsg: {messageResult}");
    
    string apiResponse = messageResult.Content.ReadAsStringAsync().Result;

    _logger.LogInformation(
quot;Log Info:  GetToken method: apiResponse: {apiResponse}");
    
    Token resTokenModel = JsonConvert.DeserializeObject<Token>(apiResponse);
    }
    catch (System.Exception ex)
    {
        _logger.LogError(
quot;Exception : GetToken Method: Exception: {ex.Message}");
        throw new Exception(ex.Message);
    }
return resTokenModel;
}

Log html response sample (it's not complete as it is very large), Log1:

2022-06-29T08:30:05.490 [Information] Log Info:  GetToken method: httpResponseMsg: StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:{Cache-Control: no-store, no-cachePragma: no-cacheStrict-Transport-Security: max-age=31536000; includeSubDomainsX-Content-Type-Options: nosniffX-Frame-Options: DENYLink: <https://aadcdn.msauth.net>; rel=preconnect; crossoriginLink: <https://aadcdn.msauth.net>; rel=dns-prefetchLink: <https://aadcdn.msftauth.net>; rel=dns-prefetchX-DNS-Prefetch-Control: onP3P: CP="DSP CUR OTPi IND OTRi ONL FIN"x-ms-request-id: 18670f19-3bec-4556-9b66-2c3760855300x-ms-ests-server: 2.1.13006.6 - WEULR1 ProdSlicesX-XSS-Protection: 0Set-Cookie: buid=0.AQIANaKxxxx_PBbRZsxxxx_PzErkPdDcCAdAA.xxxx--DLA3VO7QrddgJg7WevrDRjJU0T4KWPoylW2bC-ExpJHweIFWSInAdxjVwFITAQNF_FKbJPKHxxxxxp9ivEPYDacemz4wUo_sc04zyJbXjfz-2bVvxUz-AgAA; expires=Thu, 28-Jul-2022 08:30:05 GMT; path=/; secure; HttpOnly; SameSite=NoneSet-Cookie: fpc=AsZ-7OJNXMJAsZa7WVUJsyzxSauWAQAAAAyzTNoOAAAA; expires=Thu, 29-Jul-2022 08:30:05 GMT; path=/; secure; HttpOnly; SameSite=NoneSet-Cookie: esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrvlcjjHs6JSFKoM9RHgIe1sGicQYOARxxxxwtTCtFHUZ7DawxrkQC4x3uxxkXSFkTTUgthZA1MEqk-Pmv2mzfkL9xBHg1V-LSzxeaWxtB38SA--OJKRBbdBVRR0D80RGqwGWTn5bm4XeaaWFCt5SYYet_q1fuHwxUMe7OXIuQgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=NoneSet-Cookie: x-ms-gateway-slice=estsfd; path=/; secure; httponlySet-Cookie: stsservicecookie=estsfd; path=/; secure; httponlyDate: Tue, 28 Jun 2022 08:30:04 GMTContent-Type: text/html; charset=utf-8Expires: -1Content-Length: 195652}

from below html, I can only understand "Sign in to your account" but where to sign, Log2:

2022-06-28T08:30:05.492 [Information] Log Info: Synergi Repo: GetToken method: apiResponse:<!-- Copyright (C) Microsoft Corporation. All rights reserved. --><!DOCTYPE html><html dir="ltr" class="" lang="en"><head><title>Sign in to your account</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Expires" content="-1"><link rel="preconnect" href="https://aadcdn.msauth.net" crossorigin><meta http-equiv="x-dns-prefetch-control" content="on"><link rel="dns-prefetch" href="//aadcdn.msauth.net"><link rel="dns-prefetch" href="//aadcdn.msftauth.net"><meta name="PageID" content="ConvergedSignIn" /><meta name="SiteID" content="" /><meta name="ReqLC" content="1033" /><meta name="LocLC" content="en-US" /><meta name="referrer" content="origin" /><meta name="format-detection" content="telephone=no" /><noscript><meta http-equiv="Refresh" content="0; URL=https://login.microsoftonline.com/jsdisabled" /></noscript><meta name="robots" content="none" /><script type="text/javascript">//<![CDATA[$Config={"fShowPersistentCookiesWarning":false,"urlMsaSignUp":"https://login.live.com/oauth20_authorize.srf?response_type=code\u0026client_id=5xxx2-085c-xxxx-bf88-xxxxx8\u0026scope=openid+profile+email+offline_access\u0026response_mode=form_post\u0026redirect_uri=https%3a%2f%2flogin.microsoftonline.com%2fcommon%2ffederation%2foauth2msa\u0026state=rQQIxxxxxxFM4lbVARUISEBAuDmwnlYp99Z8dGDEFtIWogJQGEUCQ4n-_SE845sZ2UgBj5GZkYChISYycEC3QBJIREp0wIMSPBABJbO-KUFYnlLe99f-87Wxxxxkk1A8g9i0b-pawoLCQ6buGcLDlxEf2H_549xxxxvH95ugLnroRzxCot6m-DEWpr2E0_Xk7HicVcOaIUPhlJF8XSvvwZgAsAPADbzJYdaFAufQMQtA2LmBpASIaAgriAkEAjR6tf8fLM2TNfM6YhieZtvFB7ka_3-ahzdGrdTmnLvjlZXIxrK4FJ0k6sWT-Ox5qlhGJa1enI-iYRPNU_QMOFlrRnLrlQ0bNH1y3Goedpfux2982_DHb2puAy4SmU67ugsUoqztKOnUxxxxx4PMkZs0Sp1GIaYZy_EJnGgbwgTWowz5mAfE-FmyDZPEhmpPYiDGEKE2dCx7QzCmAt9GhjQtlwR2Dwj84V2d2FJBU2xl3mVxrS38LJQsijF1LQI9G1uQlwNCHSRS6AjmDBIpuX6xnahGPW5ksGXApjMgN0Z8Hw26_H4fPfYz1NXlp6IsnPjXju3PasnA0MuXsNdtFLt9thyO0zZsoqvxiuN9bONOg4vLEbDxsUzdnVQO4089KgIfhfBw325rbn_1P7iAHh3MLd7aOfbqzf3nz7-de4P0\u0026estsfed=1\u0026uaid=71c115c676664cc9bad0639fd6e7c4bf\u0026signup=1\u0026lw=1\u0026fl=easi2\u0026fci=7e7dac8e-5abd-4b36-b3f3-f312b90f7437","urlMsaLogout":"https://login.live.com/logout.srf?iframed_by=https%3a%2f%2flogin.microsoftonline.com","urlOtherIdpForget":"https://login.live.com/forgetme.srf?iframed_by=https%3a%2f%2flogin.microsoftonline.com","showCantAccessAccountLink":true,"urlGitHubFed":"https://login.live.com/oauth20_authorize.srf?response_type=code\u0026client_id=xxx-085c-xx-bf88-xxx\u0026scope=openid+profile+email+offline_access\u0026response_mode=form_post\u0026redirect_uri=https%3a%2f%2flogin.microsoftonline.com%2fcommon%2ffederation%2foauth2msa\u0026state=rQQIAxxxVE9bNNAxxxISEBAuDmwnlYp99Z8dGDEFtIWogJQGEUCQ4n-_SE845sZ2UgBj5GZkYChISYycEC3QBJIREp0wIMSPBABJbO-KUFYnlLe99f-87WUAV5JUc7gSUVTkxxxx-pawoLCQ6buGcLDlxEf2H_549P1AjD41tibs2efvH95ugLnroRzxCot6m-DEWpr2E0_Xk7HicVcOaIUPhlJF8XSvvxxxbzJYdaFAxxxxxiAkEAjR6tf8fLM2TNfM6YhieZtvFB7ka_3-ahzdGrdTmnLvxxxrK4FJ0k6sWT-Ox5qlhGJa1enI-iYRPNU_QMOFlrRnLrlQ0bNH1y3Goedpfux2982_DHb2puAy4SmU67ugsUoqztKOnUymtrLWyW56kmRshQ14PMkZs0Sp1GIaYZy_EJnGgbwgTWowz5mAfE-FmyDZPEhmpPYiDGEKE2dCx7QzCmAt9GhjQtlwR2xxxxd2FJBU2xl3mVxrS38LJQsijF1LQI9G1uQlwNCHSRS6AjmDBIpxxxxsGXApjMxxx26_H4fPfYz1NXlp6IsnPjXju3PasnA0MuXsNdxxxvxiuN9bONOg4vLEbDxsUzdnVQO4089KgIfhfBw325rbn_1P7iAHh3MLd7aOfbqzf3nz7-de4P0\u0026estsfed=1\u0026uaid=71c115c676664cc9bad0639fd6e7c4bf\u0026fci=7e7dxxxx-b3f3-f312b90f7437\u0026idp_hint=github.com","fShowSignInWithGitHubOnlyOnCredPicker":true,"fEnableShowResendCode":true,"iShowResendCodeDelay":90000,"sSMSCtryPhoneData":"AF~Afghanistan~93!!!AX~Åland Islands~358!!!AL~Albania~355!!!Islands~358!!!AL~Albania~355!!!
---------
-- and so here is large html content as above ---

--------------------------------------------------------------------------------------------------
Exception log:
This is because in code we are parsing response (so below issue is because it tried to parse response html) - so this does not seems to be useful

2022-06-29T15:18:14.657 [Error] Exception : GetToken Method: Exception: Unexpected character encountered while parsing value: '<'. Path '', line 0, position 0.
2022-06-29T15:18:14.710 [Error] Exception :  Method: Exception: One or more errors occurred. (Unexpected character encountered while parsing value: '<'. Path '', line 0, position 0.)

If anyone has faced similar issue or can give an idea what can be the cause, though it's hard to find just looking in to code

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

写给空气的情书 2025-02-18 17:31:50
  • 诸如“在解析值时遇到的意外角色:'&lt;'。路径'',第0行,位置0。几乎总是JSON解析错误。

  • 发生它的最常见原因是当被序列化的字符串实际上不是有效的json时。

  • 还检查包含JSON字符串的文件是否具有[BOM-字节订单标记]。尝试删除BOM以解决错误。

  • Errors like "Unexpected character encountered while parsing value: '<'. Path '', line 0, position 0." are almost invariably JSON parse errors.

  • The most common reason for it to occur is when the string being deserialized is not actually valid JSON.

  • Also check if the file containing JSON string had [BOM - Byte Order Mark]. Try and remove the BOM to resolve the error.

情愿 2025-02-18 17:31:50

感谢所有回答并查看此线程的人。

我们发现了实际问题,这不是来自代码/开发方面。供应商已将API迁移到Azure Server,现在它们具有另一个级别的身份验证(可能是Azure AD),

因此我认为(JWT OAUTH)正在返回它的原始身份验证,但我们没有对Azure进行身份验证,所以这可能是这样。原因我们要获得Azure HTML页面。

现在,API团队正在寻找需要做的事情。我们可以关闭此线程,或者如果有人有任何解决方案或建议,他们可以共享。

谢谢

Thanks to all who replied and viewed this thread.

We have found the actual problem and it's not from the code/development side. The vendor has migrated the API to azure server and now they have another level of authentication (might be azure Ad)

So the original authentication which I believes (JWT Oauth) is returning it's token but we are not authenticating azure one so that's might be the reason we are getting azure html page.

Now API team is looking what's need to be done. We can close this thread or if someone has any solution or suggestion they can share.

Thanks

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文