NAV 2009 R2 Classic Client and Shopify API + JSON

Hello

I need to integrated with our new Shopify shop, so NAV 2009, can get orders, update orders, products etc by some sort of automation.

Ive created a shop i Shopify, greated a private App, got the API key and the password, and when i enter the url: https://apikey:password@theshop.myshopify.com/admin/api/2020-10/orders.json

Then i get alle the orders back. So it's accesable.

I have previously worked with SOAP integrated shops, but never with REST and Json.

I've tried https://dynamics.is/?p=2303 but our NAV 2009 R2 can't use the NewtonSoft.Json assembly.

Then i tried:
OBJECT Codeunit 50053 Json Functions
{
  OBJECT-PROPERTIES
  {
    Date=16-12-20;
    Time=12:21:11;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    OnRun=VAR
            theurl@1161021000 : Text[1024];
          BEGIN
            theurl := 'https://'+ apikey + ':' + pwd + '@beeria.myshopify.com/admin/api/2020-10/orders.json';

            CallRESTWebServic(theurl);
          END;

  }
  CODE
  {
    VAR
      apikey@1161021000 : TextConst 'ENU='; // Not empty in the code,
      pwd@1161021001 : TextConst 'ENU=';    // deleted here on purpose
 
    PROCEDURE CallRESTWebServic@1161021004(url@1161021001 : Text[1024]);
    VAR
      WinHttp@1161021000 : Automation "{662901FC-6951-4854-9EB2-D9A2570F2B2E} 5.1:{2087C2F4-2CEF-4953-A8AB-66779B670495}:'Microsoft WinHTTP Services, version 5.1'.WinHttpRequest";
      JsonTxt@1161021002 : Text[1024];
      ResponseStream@1161021003 : InStream;
      ResponseBuffer@1161021004 : BigText;
      Comment@1161021005 : Record 97;
    BEGIN
      CREATE(WinHttp);
      WinHttp.Open('GET',url,FALSE);
      WinHttp.SetRequestHeader('Content-Type', 'application/json');
      WinHttp.Send('');
      ResponseStream := WinHttp.ResponseStream;
      ResponseBuffer.READ(ResponseStream);
      IF ResponseBuffer.GETSUBTEXT(JsonTxt, 1, 1024) >0 THEN;
      MESSAGE(JsonTxt);
    END;

    BEGIN
    END.
  }
}

I cheked the APIkey and password several times and they are correct, but i keep getting this as the only response in the Txt variable.

{"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}


So i'm stuck..

Any help will be highly appreciated.



Sign In or Register to comment.