HttpWebRequest := HttpWebRequest.Create('https://sandbox.spryngpayments.com/v1/api_key'); HttpWebRequest.Method := 'GET'; HttpWebRequest.Headers.Add('X-APIKEY','DUMMYAPIKEY'); ServicePointManager.SecurityProtocol(SecurityProtocol.Tls12); // new line HttpWebResponse := HttpWebRequest.GetResponse;
Answers
BaseUrl – the first part of the url that is being called, e.g.: http://www.webserviceaddress.com/
Method – the resource on the web service, in other words, the second part of the url, e.g. somecoolapi/parameter?option=value
RestMethod – one of the request verbs, either GET, POST, PUT or DELETE
HttpContent – the content to be sent with the POST or PUT command
HttpResponseMessage – the response message containing the status code and the response body. This parameter is ByVar because the calling code needs to handle the specific response itself. That’s not part of the generic pattern.
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
Unfortunately this code gives exactly the same result.
Did you try it yourself with the API I want to use ('https://sandbox.spryngpayments.com/v1/api_key')
them I am very curious for the actual code you are using.
Any other suggestions?
it's because SSL.
The HttpWebRequest-object tries to "handshake" the security-protocol with the server first.
The first attempt is SSL (because it is the "lowest" security-standard). But since it has been discovered that there is a big security-issue with SSL (heartbleed?), a lot of Webservices close the connection immediately as soon as a client tries to connect with SSL (mostly payment webservices).
You have to initiate the connection in TLS.
Try this here:
ServicePointManager is [System.Net.ServicePointManager.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089']
And SecurityProtocol is [System.Net.SecurityProtocolType.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089']
That should work.
Good luck,
Hannes
I did manage to solve it earlier today with exact that line of code.
In the mean time discovered a lot about how to use fiddler in combination with NAV in order to get to the root cause of this problem.
It was the SSL TSL12 and yes a payment provider.
Cheers!
Please accept my answer if it helps you.
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
jwilder@stonewallkitchen.com
Fiddler is a nice tool for sniffing network traffic.
It can be downloaded here: http://www.telerik.com/fiddler.
When I needed to sniff my network traffic (NAV Consume Webservice Black-Belt ) I discovered that Fiddler “out-of-the-box” does not show the Network packages from NAV.
This is cause NAV instance is running as a service and Fiddler only looks at processes within your current session.
If you need to sniff the network packages from NAV as well please follow these steps:
This is done like this:
1. Go to : C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config
2. locate the file machine.config.
3. open the file (first create a backup)
4. locate the section <system.net> (or create this section at the bottom , within configuration tag).
Update the section to:
<!-- The following section is to force use of Fiddler for all
applications, including those running in service accounts -->
<system.net>
<defaultProxy
enabled = "true"
useDefaultCredentials = "true">
<proxy autoDetect="false" bypassonlocal="false"
proxyaddress="http://127.0.0.1:8888"
usesystemdefault="false" />
</defaultProxy>
</system.net>
5. Restart NAV Service tier.
(do not forget to remove this section (use the backup from step 3) and restart NAV after sniffing.