Shopify API string lengths

Solved
Highlighted
New Member
7 0 0

Hello,

 

I have a problem that many must've already faced, and that would be the lengths of strings that the shopify API returns.

They seem to be completely undocumented, making writing a model for a REST exchange extremely painful.

 

The most recent error I've encountered is a 

ERROR: value too long for type character varying(255)
Apr 08 18:29:12 le-rapp app/web.1 2020-04-08 18:29:11.855 ERROR 3 --- [io-3374...

 

Unfortunately, which exact column that appeared on gets masked in the exception process, so I am providing my table definition below, in hope someone recognizes an ill-defined field.

 

CREATE TABLE shopify_product (
    id bigint NOT NULL,
    title character varying(1024),

    vendor character varying(255),
    handle character varying(255),
    product_type character varying(255),
    tags character varying(255),

    created_at timestamp with time zone,
    updated_at timestamp with time zone,

    shop_id bigint NOT NULL
);

CREATE TABLE shopify_product_variant (
    id bigint NOT NULL,
    product_id bigint NOT NULL,

    title character varying(1024),
    sku character varying(1024),

    price character varying(255),

    created_at timestamp with time zone,
    updated_at timestamp with time zone,
        
    taxable boolean,
    requires_shipping boolean,

    shop_id bigint NOT NULL
);

 

Could anyone point me to a resource on the field lengths or correct my tables for product fields on which this is happening?

0 Likes
Highlighted

Success.

Shopify Staff
Shopify Staff
380 45 68

Hey @Saelben,

 

Have you tried making a separate call using Postman to GET the problem resource? This should allow you to see the number of characters in each field and spot the discrepancy.

 

By just looking at your table, my guess is the tags field is too short. The tags field is returned as a single string, and depending on the number of tags the merchant has used it's very possible to exceed 255 chars.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

1 Like
Highlighted
New Member
7 0 0

My final solution used a combination of API call testing and a python script to figure out which field was too long, since a manual search through 250 entries would be painful.

 

Wish postgre would log fields, but that seems to be a long time topic in the db community

0 Likes