location_ID vs Location Name vs legacy_ID

I know most of the APIs run on location IDs.
I am working on getting the Inventory Add Mutation to work.

I can use a sku and get a location_ID from there, however Im looking to add the inventory to a location not listed on the sku’s profile.

With the locations Query, using the location Name, I can only get the legacy_id, not the Location_ID.

I saw a person create a query to go from Location_ID to a Legacy_ID, but there is no vice versa

Any suggestions?

Hi @JustinAnchored
I apologize for the delayed response about this!
There might more than one issue here, right? Let me know if that is not the case:

You are trying to add inventory to a location “not currently listed” for a product, right?
In that case, are you seeing an error?

If the legacy_id you are referring to is the location ID, you might be able to do the conversion between those two by using Base64 decoder.
This should be available on any code language, but try https://www.base64decode.org/ to see if that makes sense to you. For example:

  locations(warehouse_id: "V2FyZWhvdXNlOjExNzkw"){
    data(first: 1){
      edges {
        node {

Returns me:

  "data": {
    "locations": {
      "request_id": "6096a3fd9accc715dd6bda6a",
      "complexity": 2,
      "data": {
        "edges": [
            "node": {
              "id": "QmluOjE0OTQxMDg=",
              "legacy_id": 1494108


QmluOjE0OTQxMDg= is base64 for Bin:1494108 and 1494108 is the legacy_id of that Bin

Please let us know if we could provide a better explanation or maybe there is something else you were looking for.
Thanks again for the patience!

Thank you Tom!!!

I got it to convert, Here is the Python Code to connect to shiphero and give a location name so that you can retrieve the location_ID
This is for anyone else that may need some help with the same problem. And also please excuse my lack of any sort of coding formalities. Its like when I do drywall, Its functional, but many times not pretty…

For Anyone that would use this, don’t forget to change the xxx to your token:

import http.client
import json
import base64
print(‘Scan Location’)
y = input()
conn = http.client.HTTPSConnection(“public-api.shiphero.com”)
payload = “{“query”:”{\n\n \n location(name: \"" + y + “\”) {\n request_id\n complexity\n data {\n legacy_id\n name\n warehouse_id\n type {\n name\n }\n }\n }\n}\n"}"
headers = {
‘Authorization’: “xxxxx”,
‘Content-Type’: “application/json”
conn.request(“POST”, “/graphql”, payload, headers)
res = conn.getresponse()
data = res.read()
jdata = json.loads(data)
tt3 = “Bin:” + str(tt)
message_bytes = tt3.encode(‘ascii’)
NLoc = base64.b64encode(message_bytes)
NewLocation= NLoc.decode(‘ascii’)