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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Product update by API

(4) ShareShare
ReportReport
Posted on by 77
Hi,
I am creating a process where you can update the variant comparison prices in shopify via 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.
Someone could 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(Match, false);
        if ShopifyVariantRecord.FindSet() then begin
            repeat
                Client.DefaultRequestHeaders.Clear();
                VariantId := Format(ShopifyVariantRecord.id);
                Request.SetRequestUri('https://cdb2db-11.myshopify.com/admin/api/2024-04/variants/' + VariantId + '.json');
                Request.Method := 'PUT';
 
                AccessToken := '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';
                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
    Sohail Ahmed Profile Picture
    11,169 Super User 2026 Season 1 on at
    Are you using the default Shopify connector and extending it with your logic, or is it a custom integration with Shopify? A status code 0 usually indicates a network issue, such as a failed request or an incorrect API endpoint. Check if your API call is correctly formatted, ensure authentication headers are included, and verify that Shopify's API is accessible from your environment. Maybe this will give you a hint to resolve your issue. If this helps, please mark this answer as verified.
  • Suggested answer
    YUN ZHU Profile Picture
    99,055 Super User 2026 Season 1 on at
    Hi, hope the following can give you some hints.
    Extend the Shopify Connector
     
    Thanks.
    ZHU
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    22,128 Super User 2026 Season 1 on at
    You must reinitialize HttpRequestMessage and HttpContent inside the loop

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,926 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,158 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 533 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans