# Not able to get vendor for PO

**URL:** <https://community.shiphero.com/t/not-able-to-get-vendor-for-po/919>\
**Category:** GraphQL API\
**Created:** [October 29, 2020, 6:58am UTC](https://community.shiphero.com/t/not-able-to-get-vendor-for-po/919 "2020-10-29T06:58:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sb2020](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@sb2020](https://community.shiphero.com/u/sb2020)\
**Post date:** [October 29, 2020, 6:58am UTC](https://community.shiphero.com/t/not-able-to-get-vendor-for-po/919/1 "2020-10-29T06:58:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sb2020](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@sb2020](https://community.shiphero.com/u/sb2020)\
**Post date:** [October 29, 2020, 8:11am UTC](https://community.shiphero.com/t/not-able-to-get-vendor-for-po/919/2 "2020-10-29T08:11:22Z")

</div>

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}}}}}

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [October 29, 2020, 12:34pm UTC](https://community.shiphero.com/t/not-able-to-get-vendor-for-po/919/3 "2020-10-29T12:34:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sb2020](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@sb2020](https://community.shiphero.com/u/sb2020)\
**Post date:** [October 29, 2020, 1:04pm UTC](https://community.shiphero.com/t/not-able-to-get-vendor-for-po/919/4 "2020-10-29T13:04:26Z")

</div>

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}]

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [October 29, 2020, 8:09pm UTC](https://community.shiphero.com/t/not-able-to-get-vendor-for-po/919/5 "2020-10-29T20:09:41Z")

</div>

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:](https://www.base64decode.org/)

`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
