web
You’re offline. This is a read only version of the page.
close
Skip to main content
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,089 Super User 2025 Season 2 on at
    Product update by API
    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
    92,819 Super User 2025 Season 2 on at
    Product update by API
    Hi, hope the following can give you some hints.
    Extend the Shopify Connector
     
    Thanks.
    ZHU
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    19,160 Super User 2025 Season 2 on at
    Product update by API
    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

Responsible AI policies

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

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,285

#2
Sumit Singh Profile Picture

Sumit Singh 2,725

#3
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 2,526

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans