web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

HTTP Request failed to retrieve oath2 token

(0) ShareShare
ReportReport
Posted on by

I am trying to create a HTTP request with Concur.

Debugger stops on client.send with error- An error occurred while sending the request.

  • AL Extension Version: 3.0.126610
  • Server Version: 14.0.29537.0
var
    ReqBody: Text;
    RespBody: Text;
    XMLDoc: XmlDocument;
    URL: Text;
    contentHeader: HttpHeaders;
    request: HttpRequestMessage;
    Client: HttpClient;
   Content: HttpContent;
  response: HttpResponseMessage;

Code-
URL := 'https://us.api.concursolutions.com/oauth2/v0/token';
request.SetRequestUri(URL);
request.Method := 'POST';
Content.Writefrom(ReqBody);
Content.GetHeaders(contentHeader);
contentheader.remove('Content_Type');
contentheader.remove('Content_Length');
contentHeader.add('Content_Type', 'application/x-www-form-urlencoded');
contentHeader.add('Content-Length', '437');
request.Content := Content;
client.Send(request, response);


Note- Content type and content length are required.

Categories:
  • Glenn72 Profile Picture
    20 on at

    I have the exact same problem on my call for oauth2 token for SharePoint..

    Now, this worked earlier, and then just stopped working, so I suspect it is on the API side, and not in the code the error is located.

    On debug, the 'client.Send()' phrase returns the error, and not the status for the call.

    Did you ever come up with a solution of explanaition for this?

  • Cedric GIRARD Profile Picture
    10 on at

    Samething for me ...

  • Glenn72 Profile Picture
    20 on at

    Found out this for my case.. I happen to use Docker when developing, and the issue for me, was that docker failed to provide any DNS.

    it could be a parameter when calling New NavContainer - Updatehosts.

    Both links here:

    github.com/.../338

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans