Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

deliveryProfileUpdate mutation not working #220

Closed
RockiRider opened this issue Jul 19, 2021 · 1 comment · Fixed by #252
Closed

deliveryProfileUpdate mutation not working #220

RockiRider opened this issue Jul 19, 2021 · 1 comment · Fixed by #252

Comments

@RockiRider
Copy link

RockiRider commented Jul 19, 2021

Issue summary

The GraphQL Query for deliveryProfileUpdate is not working via Shopify.Clients.Graphql and receiving a 400 Bad Request.

 mutation ($id: ID!, $profile: DeliveryProfileInput!) { 
           var: deliveryProfileUpdate(id: $id, profile: $profile){
             profile {
               id
             }
             userErrors {
               field
               message
             }
           }
         }

This is using the Shopify.Clients.Graphql(shopName, accessToken);

Expected behavior

Should process the query and update the Shipping Profile.
The graphql query works using the Shopify GraphiQL App.
I've been using a workaround via fetch (below) which is working - However I thought I should report my error anyway.

    let updateShippingProfile = await fetch(
      `https://${shop}/admin/api/2021-07/graphql.json`,
      {
        method: "POST",
        headers: {
          "X-Shopify-Access-Token": shopAccessToken,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          query:
            'mutation{deliveryProfileUpdate(id: "gid://shopify/DeliveryProfile/' +
            deliveryProfileId +
            '", profile: {variantsToAssociate: ["gid://shopify/ProductVariant/' +
            variantId +
            '"]}){profile {id}userErrors{message}}}',
        }),
      }
    );

Error Msg

HttpResponseError: Received an error response (400 Bad Request) from Shopify: [object Object]. If you report this error, please include this id: 4ab27f39-a174-4522-9713-6843276aeaae
0|dyn    |     at HttpResponseError.ShopifyError [as constructor] (/var/www/html/node_modules/@shopify/shopify-api/dist/error.js:13:28)
0|dyn    |     at new HttpResponseError (/var/www/html/node_modules/@shopify/shopify-api/dist/error.js:95:28)
0|dyn    |     at HttpClient.<anonymous> (/var/www/html/node_modules/@shopify/shopify-api/dist/clients/http_client/http_client.js:214:55)
0|dyn    |     at step (/var/www/html/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:143:27)
0|dyn    |     at Object.next (/var/www/html/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:124:57)
0|dyn    |     at fulfilled (/var/www/html/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:114:62)
0|dyn    |     at processTicksAndRejections (internal/process/task_queues.js:97:5) {
0|dyn    |   code: 400,
0|dyn    |   statusText: 'Bad Request'
0|dyn    | }

Steps to Reproduce

  • Setup a shipping profile on a store and retrieve its ID (manually or programmatically)
  • Use the Shipping profile ID to make a GraphQL Request via deliverProfileUpdate mutation
  • Use a product's variant ID (not a product ID) within the query with the goal to attach it to the custom shipping profile

Extra information: this is all done through a Custom App and the accessToken used is an offline token

@govindrai
Copy link

I'm getting the same error but for a different api call and the error message displays [object Object] meaning the error is not being unwrapped.

creating a script tag:

const data = await ctx.state.client.post({
            path: 'script_tags',
            body: {
                "script_tag": {
                    "event": "onload",
                    "src": "https://google.com"
                }
            },
            type: DataType.JSON,
        });

returns:

 Received an error response (400 Bad Request) from Shopify: [object Object]. If you report this error, please include this id: 764305ab-f162-491c-9ab9-7ce93a835f09

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants