Personalized checkout and custom promotions with Shopify Scripts
Hi Following is my code and struct for creating shopify articles. I never had a issue with them until recently where some of the pages get created and others send a 422 Unprocessable Entity response. can someone help me sorting this out as i dont see an issue here..!
pageArticle := &ArticleRequest{
Article: Article{
Title: FinalTitle,
Author: "Hit Parader",
Tags: Tags,
BodyHTML: html,
PublishedAt: time.Now().UTC().Format("2006-01-02T15:04:05-0700"),
Image: ArticleImage{
Src: pageSRC,
Alt: title,
},
Metafields: []ArticleMeta{
{
Key: "feature_image_page_number",
Value: page,
Type: "number_integer",
Namespace: "custom",
},
},
},
}
spew.Dump(pageArticle)
articleJSON2, err := json.Marshal(pageArticle)
if err != nil {
fmt.Println(err)
}
articleReq2, err := http.NewRequest("POST", newArticleQueryFinal, bytes.NewBuffer(articleJSON2))
if err != nil {
fmt.Println(err)
}
articleReq2.Header.Add("X-Shopify-Access-Token", token)
articleReq2.Header.Add("Content-Type", "application/json")
resp3, err := client.Do(articleReq2)
if err != nil {
fmt.Println(err)
}
Struct
type ArticleRequest struct {
Article Article `json:"article"`
}
type Article struct {
Title string `json:"title"`
Author string `json:"author"`
Tags string `json:"tags"`
BodyHTML string `json:"body_html"`
PublishedAt string `json:"published_at"`
Image ArticleImage `json:"image"`
Metafields []ArticleMeta `json:"metafields"`
}
type ArticleImage struct {
Src string `json:"src,omitempty"`
Alt string `json:"alt,omitempty"`
}
type ArticleMeta struct {
Key string `json:"key"`
Value int `json:"value"`
Type string `json:"type"`
Namespace string `json:"namespace"`
}
same kind of content gives 2 response types. Im at a loss here.
Any help would be appreciated..!!!
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025