web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Shopify API

(1) ShareShare
ReportReport
Posted on by 20
Hi,
I am creating a process in which I can update the variant comparison prices in shopify using the API.
But I have a problem and it is that it sends me a status code 0 as the following message:

When it goes through the first variant in the repeat this if it is updated, if it makes the request correctly. But from then on it starts to send me this error for the following variants.
Could someone help me on what is wrong with my code or why I get this error.
The code I use is the following:
    procedure UpdatePriceIn0()
    var
        Client: HttpClient;
        Request: HttpRequestMessage;
        Response: HttpResponseMessage;
        Content: HttpContent;
        ContentHeaders: HttpHeaders;
        JsonResponse: Text;
        AccessToken: Text;
        VariantId: Text;
        UpdateJson: Text;
        ShopifyVariantRecord: Record "Shopify Variants Mercalab";
    begin
        ShopifyVariantRecord.SetRange(Coincide, false);
        if ShopifyVariantRecord.FindSet() then begin
            repeat
                Client.DefaultRequestHeaders.Clear();
                VariantId := Format(ShopifyVariantRecord.id);
                Request.SetRequestUri('https://cdb5cb-41.myshopify.com/admin/api/2024-04/variants/' + VariantId + '.json');
                Request.Method := 'PUT';
                AccessToken := 'shpat_b3135a9134c1fda5a433e4617a0157e';
                Client.DefaultRequestHeaders.Add('X-Shopify-Access-Token', AccessToken);
                UpdateJson := '{"variant":{"id": ' + VariantId + ',"compare_at_price": null}}';
                Content.WriteFrom(UpdateJson);
                Content.GetHeaders(ContentHeaders);
                ContentHeaders.Remove('Content-Type');
                ContentHeaders.Add('Content-Type', 'application/json');
                Request.Content := Content;
                if Client.Send(Request, Response) then begin
                    Content := Response.Content();
                    Content.ReadAs(JsonResponse);
                end else begin
                    Message('Error: ' + Format(Response.HttpStatusCode));
                end;
            until ShopifyVariantRecord.Next() = 0;
        end else begin
            Message('Not found');
        end;
    end;
I have the same question (0)
  • Suggested answer
    Gerardo Rentería García Profile Picture
    25,157 Most Valuable Professional on at
    Hi
    Best
    GR

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans