Error 422 Unprocessable Entity

Solved
James_Tankersle
Shopify Partner
21 1 2

I've got a script that updates or creates new products, I've been staring at the json and can't figure out where the error is, maybe a fresh set of eyes can detect the flaw?

{
"product": {
"body_html": "From a pilgrimage through the streets of Assisi to contemplative walks on the beaches near his home, Bruce Epperly has pondered the questions of privilege, prayer, and social justice while walking with the teachings of Francis of Assisi.<BR /> <br /> Stock #: AD53333",
"id": null,
"images": [
{
"src": "https://classic.catholicgreetings.org/gfx/products/9781632533333.jpg"
}
],
"published": "false",
"product_type": "Audio Book Download",
"tags": "Walking with Francis of Assisi: From Privilege to Activism Downloadable Audio Book,Bruce G. Epperly, read by Jeff Moon",
"title": "Walking with Francis of Assisi: From Privilege to Activism Downloadable Audio Book",
"metafields_global_title_tag": "Walking with Francis of Assisi: From Privilege to Activism Downloadable Audio Book",
"metafields_global_description_tag": "From a pilgrimage through the streets of Assisi to contemplative walks on the beaches near his home, Bruce Epperly has pondered the questions of privilege, pray",
"variants": [
{
"barcode": "9781632533333",
"compare_at_price": null,
"created_at": null,
"fulfillment_service": "manual",
"grams": "204.116346317401",
"id": null,
"image_id": null,
"inventory_management": "null",
"inventory_policy": "continue",
"inventory_quanity": null,
"old_inventory_quanity": null,
"inventory_quanity_adjustment": null,
"option": null,
"position": "1",
"price": "19.99",
"product_id": null,
"requires_shipping": "false",
"sku": "9781632533333",
"taxable": "true",
"title": "Walking with Francis of Assisi: From Privilege to Activism Downloadable Audio Book",
"updated_at": null,
"weight": "0.45",
"weight_unit": "lb"
}
],
"metafield": [
{
"key": "Author",
"value": "Bruce G. Epperly, read by Jeff Moon",
"value_type": "string",
"namespace": "global"
},
{
"key": "AuthorBio",
"value": "\"<B>Rev. Dr. Bruce G. Epperly</B>&#160;has served as a congregational pastor, university chaplain, professor, and seminary administrator for over forty years. He is currently Senior Pastor of South Congregational Church, United Church of Christ, Centerville, Massachusetts. He is the author of more than fifty books on practical theology, ministry, and spirituality, healing and wholeness, and process theology, including&#160;<I>The Mystic in You: Discovering a God-filled Worl</I>d, the award-winning&#160;<I>Tending to the Holy: The Practice of the Presence of God in Ministry</I>, and&#160;<I>Mystics in Action: Twelve Saints for Today</I>. He lives on Cape Cod, Massachusetts, with his wife Rev. Dr. Katherine Gould Epperly, his son, daughter-in-law, and grandchildren.<BR /> &#160;\"",
"value_type": "string",
"namespace": "global"
},
{
"key": "BISAC",
"value": "RELIGION / Christian Living / Social Issues",
"value_type": "string",
"namespace": "global"
},
{
"key": "Dimensions",
"value": " X X ",
"value_type": "string",
"namespace": "global"
},
{
"key": "FMProductID",
"value": "AD53333",
"value_type": "string",
"namespace": "global"
},
{
"key": "Form",
"value": "eAudio",
"value_type": "string",
"namespace": "global"
},
{
"key": "Imprint",
"value": "Franciscan Media",
"value_type": "string",
"namespace": "global"
},
{
"key": "NumPages",
"value": "N/A",
"value_type": "string",
"namespace": "global"
},
{
"key": "Reviews",
"value": "&ldquo;I have great respect for Dr. Bruce Epperly and, like millions of others, profound love for St. Francis. What a gift to have Bruce Epperly&#39;s reflections&#160;on this great saint whose example is needed now more than ever!&rdquo; &mdash;Brian D. McLaren, author of&#160;<I>Faith After Doubt</I><BR /> &#160;<BR /> &quot;A beautifully written account of a theologian&#39;s spiritual journey with the beloved saint. &#160;Each chapter moves us, step-by-step, a little closer to the heart of Francis, while offering a transforming vision of mystical activism for our time.&quot;&#160;&mdash;Patricia Adams Farmer, author of&#160;<I>Beauty and Process Theology</I><BR /> &#160;<BR /> &ldquo;Discover the face of Christ on this word-journey through Assisi with Bruce Epperly. He traverses the landscape, shares snapshots of his childhood in dialogue with the life and spiritual development of St. Francis, and offers offering spiritual practices that call us to greater reflection and activism.&rdquo;&#160;&mdash;Rev. Dr. Charlene Zuill, Spiritual Life Coordinator Boston University School of Theology<BR /> &#160;<BR /> &ldquo;Details of St Francis&rsquo;s teaching and exemplary life are compellingly and creatively integrated with personal reflections from the author&rsquo;s own spiritual journey, along with offering contemplative practices to ground one&rsquo;s own social justice work.&#160;&#160;The energy to continue working for environmental justice&#160;is grounded in the spiritual exercises he shares with the reader.&rdquo;&mdash;Jay Terbush, Pilgrimage Guide and Intentional Interim Minister, United Church of Christ&#160;",
"value_type": "string",
"namespace": "global"
},
{
"key": "RunTime",
"value": "275 minutes",
"value_type": "string",
"namespace": "global"
},
{
"key": "PubYear",
"value": "1/12/2021",
"value_type": "string",
"namespace": "global"
},
{
"key": "NoOfDiscs",
"value": "NA",
"value_type": "string",
"namespace": "global"
},
{
"key": "POD",
"value": "NO",
"value_type": "string",
"namespace": "global"
}
],
"vendor": "Franciscan Media"
}
}

0 Likes
florinanghel
Shopify Partner
132 17 24

I did not know you could set the metafields directly when creating the item, I usually do a separate request. Did adding the metafield product prop work before?

James_Tankersle
Shopify Partner
21 1 2

@florinanghel  This is an older script and back in the "day" you could set your metafields upon creation. When they removed the ability to do that the api seemed happy to just ignore that part of the structure. I did try a post without the metafields and got the same result.

0 Likes
_JCC_
Shopify Staff
Shopify Staff
158 21 27

This is an accepted solution.

@James_Tankersle 

Couple of things jump out at me. I believe the inventory_management specified in your example is the source of the error. The use of inventory_management should be null, shopify, or a fulfillment service handle not a string value of "null". More info on the inventory management values are described here. While not contributing to the error when creating metafields you'll want to use metafields not metafield.

Hope this helps.

Regards,

John

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog