Issue updating products

I am building the code to handle products in Shiphero for a client and I’m always getting the an error when trying to update ANY products.

Mutation:

mutation {
product_update(
data: {
sku: “TESTPRODUCT”
name: “TESTPRODUCT”
country_of_manufacture: “DE”
}
) {
request_id
complexity
}
}

Error:

{
“errors”: [
{
“message”: “Unexpected Error”,
“operation”: “product_update”,
“field”: “product_update”,
“request_id”: “5dca825e4d5202bf67acea50”,
“code”: 22
}
],
“data”: {
“product_update”: null
}
}

Hi @mpspw!
A fix was implemented for this, you should be able to update products now using that same mutation.
Let me know if you receive any other errors
Thanks!
Tom

Hi @tomasw, the product update is now working. Will post if i encounter any other issues. Thanks a lot and have a nice day :slight_smile:

Hi,

Is there a list of the various fields we can use in the product_update mutation? I tried this,

Hi,

Is there a list of the fields available to the product_update mutation? I tried this:

mutation {
product_update(
data: {
sku: “72152277-STR-10616-4096”
on_hand: 5
inventory_bin: “Test Bin”
warehouse: “Primary”
}
) {
request_id
complexity
}
}

But it gave me this error:

Exception in Task: Unhandled errors
{“message”: “Unexpected error. Please contact a system administrator.”}Error getting HTTP response: The remote server returned an error: (400) Bad Request.

Thanks.

Hi @jrtwynam

Looks like you are looking for the warehouse_product_update mutation.
That mutation will allow you to change both on hand and inventory, something like:

  mutation {
   warehouse_product_update(
    data: {
      sku: "72152277-STR-10616-4096"
      on_hand: 5
      inventory_bin: "Test Bin"
      warehouse_id: "V2FyZWhvdXNlOjY14frgt6"
    }
  ) {
    request_id
    complexity
  }
}

Product_update will allow you to change the information on the product, such as dimensions, name, country of manufacture or other characteristics, but warehouse_product_update will allow you to change values associated with inventory, such as on hand, inventory bin or some other characteristics such as price or value.

Let me know if there is anything else I can help you with.
Thanks!

At first glance, that looks like exactly what I want. Unfortunately, it didn’t work. I’ve tried this statement in various formats - exactly as it appears below, again removing all the newline characters (the API doesn’t seem to like them when it’s my automation tool that sends the request), again removing the “=” at the end of the warehouse ID (because I wasn’t sure if that was officially part of the ID since your example didn’t have one).

mutation {
   warehouse_product_update(
    data: {
      sku: "70827402-FEL-10689-MS98011T"
      on_hand: 5
      inventory_bin: "Test Bin"
      warehouse_id: "V2FyZWhvdXNlOjczOTE="
    }
  ) {
    request_id
    complexity
  }
}

Right!, = should be included as well.
Do you happen to have the request id of the mutation that you made and failed?
Thanks in advance!
Tom

No, because the request doesn’t return a request ID. This is what it returns:

Exception in Task: Unhandled errors
{"message": "Unexpected error. Please contact a system administrator."}Error getting HTTP response: The remote server returned an error: (400) Bad Request.

This is the request I sent. It’s exactly like above (with the “=” added back into the warehouse ID), except that I removed the newline characters since they seem to confuse the API.

mutation {warehouse_product_update(data: {sku: "70827402-FEL-10689-MS98011T" on_hand: 5 inventory_bin: "Test Bin" warehouse_id: "V2FyZWhvdXNlOjczOTE="}) { request_id complexity }}

This is the query that I have working for the warehouse ID:

{"query":
	"query {  
		account {    
			complexity    
			request_id    
			data {      
				id      
				legacy_id      
				email      
				username      
				status      
				is_3pl      
				warehouses  {        
					id        
					legacy_id        
					identifier      
				}    
			}  
		}
	}"
}

I find it strange that the API needs to be told twice what I’m sending it (i.e. a query) before it understands, but for some reason that’s what’s required, so I’m not complaining. I tried that same method with this mutation, thinking maybe it’d work, but still no luck. I tried both of these:

{"query": "mutation {warehouse_product_update(data: {sku: "70827402-FEL-10689-MS98011T" on_hand: 5 inventory_bin: "Test Bin" warehouse_id: "V2FyZWhvdXNlOjczOTE="}) { request_id complexity }}"}

{"mutation": "mutation {warehouse_product_update(data: {sku: "70827402-FEL-10689-MS98011T" on_hand: 5 inventory_bin: "Test Bin" warehouse_id: "V2FyZWhvdXNlOjczOTE="}) { request_id complexity }}"}

Is there any way to get the API to return more information? Simply saying “bad request” doesn’t tell me much. To me, what it means is that there’s a syntax error in the JSON I’m trying to send, but it doesn’t give me any hint as to where the error is. It’d be nice if it said “missing colon near position 43”, “missing close curly brace near position 156”, “invalid warehouse ID”, or something more informative like that. Or at the very least, continued to say “bad request” but did return a request ID so that I could provide that to you.

Yes, the query should look something like this:

query {  
		account {    
			complexity    
			request_id    
			data {      
				id      
				legacy_id      
				email      
				username      
				status      
				is_3pl      
				warehouses  {        
					id        
					legacy_id        
					identifier      
				}    
			}  
		}
	}

What are you using to send the request? It may not be formatting the query/mutation correctly.
If you use Altair, GraphQL Playground or Insomnia IDEs, for example, do this query work on your account?

Another debug option would be to redirect that exact same mutation to some test endpoint such as the ones at https://requestbin.com/
And compare between the IDE and your APP, then see what’s missing and try to make them match

The one I’ve been trying with is VisualCron. I’ve gotten the Auth Token and Warehouse ID stuff to work, but it doesn’t want to work with anything else. I’ve also installed the Altair desktop client, but I can’t get that to do anything since it doesn’t like the API url:

I remember having that problem with the desktop client several months ago, so I installed the Chrome client (which worked), but now it seems my company has locked down that extension so I can’t turn it back on.

Well don’t I feel dumb now. The Altair desktop client wasn’t working because I forgot to add my auth token in the header. I’ll play around with that for a bit and see if I can figure something out.

I figured it out. This is the exact JSON that I pasted into Altair:

mutation {
   warehouse_product_update(
    data: {
      sku: "70827402-FEL-10689-MS98011T"
      on_hand: 5
      inventory_bin: "Test Bin2"
      warehouse_id: "V2FyZWhvdXNlOjczOTE="
    }
  ) {
    request_id
    complexity
  }
}

Using Fiddler to capture HTML traffic, I found that this is the exact JSON that Altair sent to the API:

{"query":"mutation {\n warehouse_product_update(\n data: {\n sku: \"70827402-FEL-10689-MS98011T\"\n on_hand: 5\n inventory_bin: \"Test Bin2\"\n warehouse_id: \"V2FyZWhvdXNlOjczOTE=\"\n }\n ) {\n request_id\n complexity\n }\n}","variables":{},"operationName":null}

So in particular, whenever something gets sent to the API, for some reason it has to be surrounded in this:

{"query": " <insert your JSON here> "}

That part, I had already been doing in my automation tool. But, notice that the JSON you want to send is enclosed in quotes. What was causing the issue is that the JSON itself also included quotes, which I needed to escape in the string. Once I did that, things started to work.

1 Like