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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

How to handle webRequest Error?

(0) ShareShare
ReportReport
Posted on by

Hi All,

I have an issue when i got error from HttpWebResponse it's shows always "Remote server can be found (400) : Bad request" but this is not my exact error means that my error is Email address is not valid or customer already exist.

i got an correct response in NAV 2016 with in bulit dll's like system.net.http and i con't find this dll in NAV 2009 R2 and my solution will not work this error message getting part because of dll so for that by R&D i found below link

http://www.dynamics.is/?p=1255

as per above link i tried and same error "Remote server can be found (400) : Bad request"  it's not my exact error.

so please provide any solution for this.

Thank You

ramesh

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    keoma Profile Picture
    32,729 on at

    for usage with nav 2009 you need .net framework 2.0 (3.5). won't work with newer .net frameworks.

    System.Net.HttpWebResponse also exists in .net 2.0, assembly System.dll:

    'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpWebResponse

  • ManishS Profile Picture
    86 on at

    Have you used postmaster google addon to check the response and request.

    May be your request is not correct.

  • Community Member Profile Picture
    on at

    Hi Jonathan,

    i have used same HttpWebResponse when i get the response

    HttpWebResponse := HttpWebRequest.GetResponse;

    in the above statement i got an error "Remote server can be found (404) : Bad request" but this is not an exact error Email address not exist my error to get an exact error message i have used System.net.Http dll see below my code

    HttpContent := StringContent.StringContent(Json,SText.UTF8,'application/json');

    HttpClient := HttpClient.HttpClient;

    HttpClient.DefaultRequestHeaders.Authorization := HttpHeader.AuthenticationHeaderValue('Bearer','xg7s6d17jc70l6vebduhyxjugp4a78hk');

    HttpResponseMessage := HttpResponseMessage.HttpResponseMessage;

    IF MagentoConnectionP."HTTP Request Method" = 'POST' THEN

      HttpResponseMessage := HttpClient.PostAsync(MagentoRestAPIURL,HttpContent).Result;

    IF MagentoConnectionP."HTTP Request Method" = 'PUT' THEN

      HttpResponseMessage := HttpClient.PutAsync(MagentoRestAPIURL,HttpContent).Result;

    IF MagentoConnectionP."HTTP Request Method" = 'GET' THEN

      HttpResponseMessage := HttpClient.GetAsync(MagentoRestAPIURL).Result;

    HandleText := HttpResponseMessage.Content.ReadAsStringAsync().Result;

    ERROR(HandleText);

    see dll variables i used here

    Name DataType Subtype Length

    HttpResponseMessage DotNet System.Net.Http.HttpResponseMessage.'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

    HttpClient DotNet System.Net.Http.HttpClient.'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

    HttpContent DotNet System.Net.Http.HttpContent.'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

    StringContent DotNet System.Net.Http.StringContent.'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

    HttpHeader DotNet System.Net.Http.Headers.AuthenticationHeaderValue.'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

    All the variables belongs to System.Net.Http dll but i con't find this dll in nav 2009 R2 is there any alternate solution for this.

    Thank You

    Ramesh

  • Community Member Profile Picture
    on at

    Hi Manish,

    i have tested restful client i got error message Remote server can not be found(404):Bad request but not an exact error for getting exact error i written code please see reply what i have given to Jonathan.

    the code i have written in nav 2016  with advanced dll's how should i get this exact dll in nav 2009 R2 too.

  • Verified answer
    keoma Profile Picture
    32,729 on at

    for usage with nav 2009 you need an older version of system.net.http. system.net.http is not part of .net framework, it's an additional library from nuget.

    for the older version of system.net.http, which is usable with .net framework 2.0/3.5, goto

    www.nuget.org/.../2.0.20710 and

    www.nuget.org/.../2.0.20710

    alternatively you could try to develope a code without using these nuget libraries.

  • ManishS Profile Picture
    86 on at

    you can user XMLdoc & XMLhttp automation.

  • Community Member Profile Picture
    on at

    Hi Ramesh,

    did you get a solution to your error? I am having the same problem. Thanks

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans