HTTP call error to shopify fails when sending array in json request

3 0 0

This is an http post response to create a new shopify blog with metadata values.


blog := Blog{
        Title:           fileNameWithoutExtSliceNotation(doc.Name()),
        Template_suffix: "hit_parader_issue_template",
        Metafields: []BlogMeta{
                Key:       "filter_tag_list",
                Value:     "Popular",
                Type:      "single_line_text_field",
                Namespace: "global",

        blogJSON, err := json.Marshal(blog)
        blogReq, err := http.NewRequest("POST", newBlogQuery, bytes.NewBuffer(blogJSON))
        blogReq.Header.Add("X-Shopify-Access-Token", TOKEN)
        blogReq.Header.Add("Content-Type", "application/json")

resp1, err := client.Do(blogReq)

my structs are like below

type Blog struct {
    Title           string `json:"title"`
    Template_suffix string `json:"template_suffix"`
    Metafields      []BlogMeta

type BlogMeta struct {
    Key       string
    Value     string
    Type      string
    Namespace string

im getting an error saying

{"errors":{"blog":"Required parameter missing or invalid"}}

These are my blog metafield definitions.




I have all the necessary fields listed in the following api call. Please help.

Im using below API

NOTE: the API documentation says that I need to present a array for the metafields. But I think my code is correct. IS there something im missing? Any help would be appreciated.

Replies 0 (0)