Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Need Help to Certificate Authentication For Rest API from NAVISION.

Posted on by 190

Hi EveryOne am trying to Send Request in Json and get the response from Navision, Am New to Dot.Net Variables.

Below is Code i have Tried So Far

HttpwebreqHan := HttpwebreqHan.WebRequestHandler();
HttpwebreqHan.ClientCertificateOptions(HttpClientCerOpt.Manual);
X509Store := X509Store.X509Store(X509StoreName.My,X509StoreLocation.CurrentUser);
X509Store.Open(X509OpenFlags.ReadOnly);
X509Store := X509Store.Certificates.Find(X509StoreType.FindBySubjectName,'J5UKSH8F',TRUE);
HttpwebreqHan.ClientCertificates();
HttpClient := HttpClient.HttpClient(HttpwebreqHan);

BaseUrl := 'vsdc.staging.vms.frcs.org.fj/.../Sign'; // Added

INvc := '0010001335';
StringContent := StringContent.StringContent(GetJsonInvoice_StructureString(INvc,sas),Encoding.UTF8,'application/json');

HttpClient.BaseAddress := Uri.Uri(BaseUrl);


HttpResponseMessage := HttpClient.PostAsync('POST',StringContent).Result; // Error Coming At this Point


IF HttpResponseMessage.IsSuccessStatusCode THEN
result := HttpResponseMessage.Content.ReadAsStringAsync.Result;

The Error Is Saying like Below


A call to System.Threading.Tasks.Task`1[System.Net.Http.HttpResponseMessage].Result failed with this message: The remote certificate is invalid according to the validation procedure.
---------------------------
OK
---------------------------

*This post is locked for comments

  • Wolfram Ansin Profile Picture
    Wolfram Ansin 5 on at
    RE: Need Help to Certificate Authentication For Rest API from NAVISION.

    Dear Raja,

    I try to consume a SOAP-Webservice from NAV2017 with client-certificate and want to use a code like yours. But I can't find a DotNet-variable for X509store in NAV. Please can you tell me what variables (DotNet with complete Assemply ...) you used? If I have success I will tell you, so maybe you will be able to solve your problem (even it is about 18 month old). Tnx.

    Best regards, Wolfram

  • Raja Venkat Profile Picture
    Raja Venkat 190 on at
    RE: Need Help to Certificate Authentication For Rest API from NAVISION.

    Hi Alexander,

    Thanks for reply . Its like Hierarchy of Certificates  i have added it in Trusted Certificate Root. what i think is its Not loaded in HttpClient Variable with which it has to send request.. Its a Bad Request. Do you got anything related to this like code that might be very useful.

  • Suggested answer
    Alexander Ermakov Profile Picture
    Alexander Ermakov 28,094 on at
    RE: Need Help to Certificate Authentication For Rest API from NAVISION.

    Please check first the following failure options:

    your current certificate is self-signed and not added as a trusted certificate

    certificate is expired

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans