Can't we update Inventory via API

Hello Community

I am using GraphQL APIs,
I tried to update the inventory using API, but I couldn’t do the same and I am getting following in response:
{
“errors”: [
{
“message”: “Unexpected Error”,
“operation”: “inventory_add”,
“field”: “inventory_add”,
“request_id”: “5f4cc8af5d41db2c839fcf7a”,
“code”: 22
}
],
“data”: {
“inventory_add”: null
}

Here is my request looks like:

mutation {
inventory_add(data: {
sku: “Keyboard001”
quantity: 111,
warehouse_id:“V2FyZWhvdXNlOjExNTU3”
}) {
request_id
complexity
warehouse_product {
id
sku
warehouse_id
on_hand
}
}
}

Is it not possible to update the Inventory using API, Or Something is wrong with my request?
Please help :slight_smile:

Thanks in Advance :blush:

Hi @khungersumit
It looks like the bearer that you are using belongs to a user on an Customer account, which is a customer from a 3PL account (which happens to be canceled)
That is why it is not allowing you to change inventory.

When making inventory changes, those need to be made from a 3PL Account. In this case, you will need to use a Bearer that belongs to a user from the 3PL account, and specify the customer_account_id. Something like this:

mutation {
  inventory_add(
    data: {
      sku: "Keyboard001"
      quantity: 111
      warehouse_id: "V2FyZWhvdXNlOjExNTU3"
      customer_account_id: "QWNjb3VudDo1NDcyNg=="
    }
  ) {
    request_id
    complexity
    warehouse_product {
      id
      legacy_id
      account_id
      sku
      warehouse_id
      warehouse_identifier
      price
      value
      value_currency
      on_hand
    }
  }
} 

But you might need to contact the 3PL and ask why the account has been canceled first.
Let me know if I can provide a better explanation or there is anything else I could help with!
Thanks
Tom

Hi @tomasw
Thanks for responding

I integrated my Shopify sales channel and sync all the products from shopify to shiphero.

My question is where to get this customer_account_id :thinking:

sure! you can use this Query:

query {
  account {
    request_id
    complexity
    data {
      id
      legacy_id
      warehouses {
        id
        legacy_id
      }
      customers {
        edges {
          node {
            id
            legacy_id
            username
            email
          }
        }
      }
    }
  }
}

but this will have to be done with a bearer from the 3PL. Otherwise, the customers section will return empty

1 Like