# How to add location while creating purchase order via API

**URL:** https://community.shiphero.com/t/how-to-add-location-while-creating-purchase-order-via-api/836
**Category:** GraphQL API
**Created:** [September 24, 2020, 5:12am UTC](https://community.shiphero.com/t/how-to-add-location-while-creating-purchase-order-via-api/836 "2020-09-24T05:12:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![supritha](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@supritha](https://community.shiphero.com/u/supritha)
#### Post date: [September 24, 2020, 5:12am UTC](https://community.shiphero.com/t/how-to-add-location-while-creating-purchase-order-via-api/836/1 "2020-09-24T05:12:36Z")

</div>

Hi,

I’m trying to add location\_id/location\_name while creating purchase order via API using mutation **purchase\_order\_create** , but I’m getting error as **In field line\_items: In element #0: In field location\_id: Unknown field.**

**The mutation I used is :**

```
mutation {
  purchase_order_create(
    data: {
      po_date: "2020-09-24"
      po_number: "test-po"
      subtotal: "230.00"
      shipping_price: "0.00"
      total_price: "230.00"
      warehouse_id: "V345yZWhvdXNlOjY0NzE2"
      line_items: [
        {
          sku: "TestSKU"
          quantity: 6
          expected_weight_in_lbs: "1.00"
          vendor_id: "VmVuZG9ye5YM1MzU2MA=="
          vendor_sku:"VendorTestSKU"
          quantity_received: 0
          quantity_rejected: 0
          price: "200.00"
          product_name: "Product for testing Purchase Orders"
          fulfillment_status: "pending"
          sell_ahead: 0
          location_id:"QmluOj5YODQ0MTI="
        }
      ]
      fulfillment_status: "pending"
      discount: "0.00"
    }
  ) {
    request_id
    complexity
  }
} 

```

**I’m getting error as :**

`"message": "Argument \"data\" has invalid value In field \"line_items\": In element #0: In field \"location_id\": Unknown field."`

Please help me to add location details while creating purchase order.

Thanks in advance!

---

<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: [September 24, 2020, 12:49pm UTC](https://community.shiphero.com/t/how-to-add-location-while-creating-purchase-order-via-api/836/2 "2020-09-24T12:49:43Z")

</div>

Hi @supritha!  
The reason you are seeing the error is that we don’t have the ability to set a Location when creating the Purchase Order, because the location is chosen while in the process of receiving the items (and not when creating the purchase order)  
Its something like the flow we have defined on [https://developer.shiphero.com/purchase-orders/](https://developer.shiphero.com/purchase-orders/)

Let me know if this doesn’t help or if I could explain better.  
Thanks in advance!  
Tom

---

<div class="post-metadata">

### Author: ![supritha](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@supritha](https://community.shiphero.com/u/supritha)
#### Post date: [September 25, 2020, 3:48am UTC](https://community.shiphero.com/t/how-to-add-location-while-creating-purchase-order-via-api/836/3 "2020-09-25T03:48:53Z")

</div>

@tomasw,

I get it now. Thanks much!
