HttpWebRequest Cookies

ITNoobITNoob 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.
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&amp;enforce_merge=false&amp;merge_ignore_postponed=false&amp;prompt=merge&amp;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&amp;ui_locales=en&amp;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

Comments

Sign In or Register to comment.