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

  • Community Member Profile Picture
    on at
    RE: How to handle webRequest Error?

    Hi Ramesh,

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

  • ManishS Profile Picture
    80 on at
    RE: How to handle webRequest Error?

    you can user XMLdoc & XMLhttp automation.

  • Verified answer
    keoma Profile Picture
    32,727 on at
    RE: How to handle webRequest Error?

    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.

  • Community Member Profile Picture
    on at
    RE: How to handle webRequest Error?

    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.

  • Community Member Profile Picture
    on at
    RE: How to handle webRequest Error?

    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

  • ManishS Profile Picture
    80 on at
    RE: How to handle webRequest Error?

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

    May be your request is not correct.

  • Suggested answer
    keoma Profile Picture
    32,727 on at
    RE: How to handle webRequest Error?

    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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans