Not able to get vendor for PO

Hello,
I’m not able to get vendor information when query purchase orders (vendor id, name, etc is empty in response).

Example query:
query {purchase_order(id:“UHVyY2hhc2VPcmRlcjo2MDA4ODY”) {data {id,po_number,vendor_id, vendor {id, legacy_id, name, email} } } }

Response:
{“errors”:[{“message”:“Unexpected Error”,“operation”:“purchase_order”,“field”:“id”,“request_id”:“5f9a62f0a93510481261fedb”,“code”:22}],“data”:{“purchase_order”:{“data”:{“id”:“UHVyY2hhc2VPcmRlcjo2MDA4ODY=”,“po_note”:null,“description”:null,“legacy_id”:600886,“po_number”:“TO 8635”,“partner_order_number”:null,“vendor_id”:“VmVuZG9yOjA=”,“vendor”:{“id”:null,“legacy_id”:0,“name”:null,“email”:null}}}}}

Could you please help with this issue. Get correct vendor names for POs is crucial for our intergation.

Thank you

Here is the same issue for another account:
Query:
query {purchase_order(id:“UHVyY2hhc2VPcmRlcjo2MDA4ODY”) {data {id,po_number,vendor_id, vendor {id, legacy_id, name, email} } } }

Response:
{“errors”:[{“message”:“Unexpected Error”,“operation”:“purchase_order”,“field”:“id”,“request_id”:“5f9a78cee487d94c76c21242”,“code”:22}],“data”:{“purchase_order”:{“data”:{“id”:“UHVyY2hhc2VPcmRlcjo1Njk3OTU=”,“po_number”:“93805”,“vendor_id”:“VmVuZG9yOjA=”,“vendor”:{“id”:null,“legacy_id”:0,“name”:null,“email”:null}}}}}

Hi @sb2020!
That is because the Vendor name or id should be fetched at a line item level because the PO could have more than one vendor associated.
You could use for example this Query:

 query {
  purchase_order(id: "UHVyY2hhc2VPcmRlcjo2MDA4ODY=") {
    data {
      id
      po_note
      description
      legacy_id
      po_number
      partner_order_number
      line_items {
        edges {
          node {
            vendor {
              id
              name
            }
          }
        }
      }
    }
  }
}

Let me know if that doesn’t help,
Thanks in advance!
Tom

Yes it works, thank you!

Could you please also check why we received errors in the query response:
“errors”:[{“message”:“Unexpected Error”,“operation”:“purchase_order”,“field”:“id”,“request_id”:“5f9a78cee487d94c76c21242”,“code”:22}]

I apologize for not clarifying that @sb2020!
That is because there is a vendor connection in there:

vendor {
        id
        legacy_id
        name
        email
      }

But the Vendor is not being recognized at a Purchase Order level.

"vendor_id": "VmVuZG9yOjA=",

Which in Base64 is decoded as:

Vendor:0

And then it tries to pull a vendor from your account with id = 0. But as it doesn’t exist, it returns the error.

I have already reported this for our engineers to fix, but in the meantime you could avoid sending vendor or vendor id at a Purchase Order level, but send it on the Line Item level, like this:

query {
  purchase_order(id: "UHVyY2hhc2VPcmRlcjo2MDA4ODY=") {
    data {
      id
      po_note
      description
      legacy_id
      po_number
      partner_order_number
      line_items {
        edges {
          node {
            vendor {
              id
              name
            }
          }
        }
      }
    }
  }
}

In order to avoid the unexpected error.
Thanks again!
Tom