# API Logs & 500 errors

**URL:** <https://developer-forum.veeqo.com/t/api-logs-500-errors/103>\
**Category:** API Queries (How To)\
**Created:** [March 8, 2018, 2:04pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103 "2018-03-08T14:04:36Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![tam](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/tam/32/44_2.png) [@tam](https://developer-forum.veeqo.com/u/tam)\
**Post date:** [March 8, 2018, 2:04pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/1 "2018-03-08T14:04:36Z")

</div>

I keep getting 500 errors when posting & putting to various end-points (not all the time, but often enough). Is there somewhere I can see Veeqo’s logs to try and better debug what the problem is, and whether it’s something I can fix?

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/7A66F9/32.png) [@nathan](https://developer-forum.veeqo.com/u/nathan)\
**Post date:** [March 8, 2018, 2:15pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/2 "2018-03-08T14:15:45Z")

</div>

Hey Tam,

Unfortunately we don’t expose our logs to the public. If you let me know the `user ID` you’re using (check response for `created_by_id` or `updated_by_id` ) I can help diagnose.

Normally we only see 500 errors during development.

---

<div class="post-metadata">

**Author:** ![tam](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/tam/32/44_2.png) [@tam](https://developer-forum.veeqo.com/u/tam)\
**Post date:** [March 8, 2018, 2:17pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/3 "2018-03-08T14:17:41Z")

</div>

User ID: 24640

_Something something 20 characters something_

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/7A66F9/32.png) [@nathan](https://developer-forum.veeqo.com/u/nathan)\
**Post date:** [March 8, 2018, 2:42pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/4 "2018-03-08T14:42:32Z")

</div>

```auto
ActiveRecord::UnknownAttributeErrorproducts#update
unknown attribute 'weight_unit' for ProductVariant.

```

try not including weight\_unit

```auto
NoMethodError orders#create
undefined method `id' for nil:NilClass

```

Your request was missing a “customer\_id”

Can you double check the `customer_id` that you’re sending. If you have any other issues then let me know.

---

<div class="post-metadata">

**Author:** ![tam](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/tam/32/44_2.png) [@tam](https://developer-forum.veeqo.com/u/tam)\
**Post date:** [March 8, 2018, 2:57pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/5 "2018-03-08T14:57:17Z")

</div>

I’ve made those changes, but I’m still getting 500 errors.

It would be nice if the API responded with the errors rather than just 500ing, since your API and docs seem to be at odds with each other.

---

<div class="post-metadata">

**Author:** ![phil](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/phil/32/43_2.png) [@phil](https://developer-forum.veeqo.com/u/phil)\
**Post date:** [March 8, 2018, 3:04pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/6 "2018-03-08T15:04:34Z")

</div>

please can you send the full request you’re making?

What do you mean about the API and docs being at odds with each other. I’m always keen to hear feedback and improve our documentation.

---

<div class="post-metadata">

**Author:** ![tam](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/tam/32/44_2.png) [@tam](https://developer-forum.veeqo.com/u/tam)\
**Post date:** [March 8, 2018, 3:15pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/7 "2018-03-08T15:15:15Z")

</div>

The order (ignore the PHP array dump, I’m sending JSON):

```auto
Array
(
    [order] => Array
        (
            [channel_id] => 49947
            [customer_id] => 12843556
            [delivery_method_id] => 191837
            [deliver_to_attributes] => Array
                (
                    [first_name] => Not
                    [last_name] => My
                    [address1] => Real
                    [address2] => 
                    [city] => Address
                    [state] => Lorem
                    [country] => GB
                    [zip] => F4K3 71P
                    [customer_id] => 12843556
                )

            [number] => eace43a65132597b0dbad098f5197145
            [send_notification_email] => false
            [total_discounts] => 0
            [line_items_attributes] => Array
                (
                    [0] => Array
                        (
                            [sellable_id] => 18320411
                            [price_per_unit] => 14.9900
                            [quantity] => 1
                            [tax_rate] => 0
                            [taxless_discount_per_unit] => 0
                        )

                )

            [payment_attributes] => Array
                (
                )

        )

)

```

Regarding the docs:

- `unknown attribute 'weight_unit' for ProductVariant` - According [to the docs](https://developer.veeqo.com/docs#/reference/products/product-collection/create-a-new-product) `weight_unit` is at the product variant level.
- `customer_id` isn’t mention in the [Order attributes](https://developer.veeqo.com/docs#/reference/orders/order-collection/create-a-new-order) (but is in the request example).
- The [Create Product attributes](https://developer.veeqo.com/docs#/reference/products/product-collection/create-a-new-product) are all top level, when they need to be within a `product` object (again, this is in the request example, which I should probably rely on rather than the attributes).

---

<div class="post-metadata">

**Author:** ![phil](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/phil/32/43_2.png) [@phil](https://developer-forum.veeqo.com/u/phil)\
**Post date:** [March 8, 2018, 3:28pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/8 "2018-03-08T15:28:42Z")

</div>

The examples are, in general, a bit more in depth than the attributes.

I’ve tried really hard to provide varied and comprehensive examples, particularly for creating orders as this is something that normally takes a few attempts to get right.

Please can you include a `payment_type` if you are sending `payment_attributes`. This is actually covered in the attributes and the examples!

---

<div class="post-metadata">

**Author:** ![phil](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/phil/32/43_2.png) [@phil](https://developer-forum.veeqo.com/u/phil)\
**Post date:** [March 8, 2018, 3:40pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/9 "2018-03-08T15:40:40Z")

</div>

I’ve also added `customer_id` back to the required order attributes. Not sure why it had decided to disappear, thank you for pointing that out.

I’m not sure why `weight_unit` isn’t working. It has done for me in the past.

---

<div class="post-metadata">

**Author:** ![tam](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/tam/32/44_2.png) [@tam](https://developer-forum.veeqo.com/u/tam)\
**Post date:** [March 8, 2018, 3:45pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/10 "2018-03-08T15:45:20Z")

</div>

Posting orders is working now! Still getting a 500 error with products.  
This is what I’m sending (I’ve removed the image URLs):

```auto
Array
(
    [method] => PUT
    [endPoint] => products/12562973
    [body] => Array
        (
            [product] => Array
                (
                    [title] => Microbe-Lift All-In-One
                    [product_variants_attributes] => Array
                        (
                            [0] => Array
                                (
                                    [title] => 118ml
                                    [price] => 9.9900
                                    [sku_code] => 097121211217
                                    [weight_grams] => 0
                                )

                            [1] => Array
                                (
                                    [title] => 236ml
                                    [price] => 14.9900
                                    [sku_code] => 097121211224
                                    [weight_grams] => 0
                                )

                            [2] => Array
                                (
                                    [title] => 473ml
                                    [price] => 20.9900
                                    [sku_code] => 097121211231
                                    [weight_grams] => 0
                                )

                        )

                    [images_attributes] => Array
                        (
                            [0] => Array
                                (
                                    [src] => (...)
                                    [display_position] => 1
                                )

                            [1] => Array
                                (
                                    [src] => (...)
                                    [display_position] => 2
                                )

                            [2] => Array
                                (
                                    [src] => (...)
                                    [display_position] => 3
                                )

                        )

                    [weight_unit] => g
                )

        )

)

```

---

<div class="post-metadata">

**Author:** ![phil](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/phil/32/43_2.png) [@phil](https://developer-forum.veeqo.com/u/phil)\
**Post date:** [March 8, 2018, 3:51pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/11 "2018-03-08T15:51:57Z")

</div>

the only thing that doesn’t look right to me in that request is the `weight_unit` attribute at the end.  
Please can you try a test without this?

---

<div class="post-metadata">

**Author:** ![tam](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/tam/32/44_2.png) [@tam](https://developer-forum.veeqo.com/u/tam)\
**Post date:** [March 8, 2018, 4:03pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/12 "2018-03-08T16:03:31Z")

</div>

Completely removing `weight_unit` works. It always fails if I try to include it anywhere (either on the product or in a variant). I’m converting all weights to grams, and the response includes `weight_unit` as `g` so I guess it’s fair to assume that grams is the default?

---

<div class="post-metadata">

**Author:** ![phil](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/phil/32/43_2.png) [@phil](https://developer-forum.veeqo.com/u/phil)\
**Post date:** [March 8, 2018, 4:08pm UTC](https://developer-forum.veeqo.com/t/api-logs-500-errors/103/13 "2018-03-08T16:08:47Z")

</div>

`weight_unit` doesn’t need to be included in the product. It should inherit from the channel.

That would be a safe assumption.
