HttpWebRequest Cookies

ITNoob
Member Posts: 4
Hello,
I am currently in the process of building an interface to Shopify.
With my POST request it is important that no cookies are passed, because Shopify blocks this in my case.
In Postman you can see this nicely. With cookies it does not work, without it works without problems.
But in my code I do not have any cookies with me. Nevertheless I get exactly the same result as if I have cookies with Postman.
My code looks like this. Im Using NAV 2015.
If I get the number of cookies before the "GetResponse" is 0, I still get the same message as with Postman.
It seems that I have to use a cookie container as well, otherwise I get an error message.
In the internet I have always found cookies as the cause, so I assume that this is also the problem in my case.
Does anyone have a tip? Is NAV doing anything in the background?
Thank you and greetings
I am currently in the process of building an interface to Shopify.
With my POST request it is important that no cookies are passed, because Shopify blocks this in my case.
In Postman you can see this nicely. With cookies it does not work, without it works without problems.
But in my code I do not have any cookies with me. Nevertheless I get exactly the same result as if I have cookies with Postman.
My code looks like this. Im Using NAV 2015.
servicePointManagerL.SecurityProtocol := securityProtocolTypeL.Tls12; HttpWebRequest := HttpWebRequest.Create(_URL); HttpWebRequest.Credentials := netWorkCredentialL.NetworkCredential("Shopify Username","Shopify Password"); HttpWebRequest.Method := _Method; cookieContainerL := cookieContainerL.CookieContainer; HttpWebRequest.CookieContainer := cookieContainerL; HttpWebRequest.ContentType := 'application/json'; IF _Content <> '' THEN BEGIN requestStreamL := HttpWebRequest.GetRequestStream; streamWriterL := streamWriterL.StreamWriter(requestStreamL,encodingL.UTF8); streamWriterL.Write(_Content); streamWriterL.Flush; streamWriterL.Close; streamWriterL.Dispose; END; HttpWebRequest.KeepAlive := TRUE; HttpWebRequest.AllowAutoRedirect := TRUE; HttpWebRequest.PreAuthenticate := TRUE; HttpWebRequest.Timeout := 600000; HttpWebResponse := HttpWebRequest.GetResponse;
If I get the number of cookies before the "GetResponse" is 0, I still get the same message as with Postman.
<html> <body> <noscript> <a href="https://app.shopify.com/services/login/identity?destination_uuid=462fae67-6626-4602-b6cf-cea45e60ec6c&enforce_merge=false&merge_ignore_postponed=false&prompt=merge&return_to=https%3A%2F%2Fapp.shopify.com%2Fservices%2Flogin%2Fidentity_callback%3Ffrom_signup%3Dfalse%26locale%3Den%26shop_name%3DBollerwagen%2BSandbox%26state%3DH9JAE0aivZJsc6uu7mWhpH-eUJYYnIwuSvIsq_I95TZLGc842Tyr66_IsDwe0jEKLoyOn3iUi74WVhzvzCF0yqgrC5GhuXR_ZH_QeSk_fO15wYuA3I0U0XoBwMskmWq6tomxpGOnEIH-vyCkifUA7VEx3F1PgwUYGh22l2UZ1t3aJsroISz2iDAw7z3SHZo95k1nD5FOcdo9cOXh0phiksAkE9j2OA-hPCnEASlVd8c%253D&ui_locales=en&ux=shop">Continue</a> </noscript> <script type="text/javascript"> window.location = "https:\/\/app.shopify.com\/services\/login\/identity?destination_uuid=462fae67-6626-4602-b6cf-cea45e60ec6c\u0026enforce_merge=false\u0026merge_ignore_postponed=false\u0026prompt=merge\u0026return_to=https%3A%2F%2Fapp.shopify.com%2Fservices%2Flogin%2Fidentity_callback%3Ffrom_signup%3Dfalse%26locale%3Den%26shop_name%3DBollerwagen%2BSandbox%26state%3DH9JAE0aivZJsc6uu7mWhpH-eUJYYnIwuSvIsq_I95TZLGc842Tyr66_IsDwe0jEKLoyOn3iUi74WVhzvzCF0yqgrC5GhuXR_ZH_QeSk_fO15wYuA3I0U0XoBwMskmWq6tomxpGOnEIH-vyCkifUA7VEx3F1PgwUYGh22l2UZ1t3aJsroISz2iDAw7z3SHZo95k1nD5FOcdo9cOXh0phiksAkE9j2OA-hPCnEASlVd8c%253D\u0026ui_locales=en\u0026ux=shop"; </script> </body> </html>
It seems that I have to use a cookie container as well, otherwise I get an error message.
In the internet I have always found cookies as the cause, so I assume that this is also the problem in my case.
Does anyone have a tip? Is NAV doing anything in the background?
Thank you and greetings
0
Comments
-
Hello, everyone,
I couldn't solve my problem. Then I found out there was "ShopifySharp".
https://github.com/nozzlegear/ShopifySharp[/url].
I was able to map everything successfully with it.
Greetings1
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions