Post request for product and script tag

Solved
Highlighted
Tourist
3 0 2

Hi All,

 

I am new at Shopify App Development.I was trying to do post request to add  product on my store.My post request is:

 

 "https://<my_apps_API_Key>:<acessToken>@<store_name>..myshopify.com/admin/api/2020-01/products.json"

 

 

the params are:

 

{

  "product": {

    "title": "Burton Custom Freestyle 151",

    "body_html": "<strong>Good snowboard!</strong>",

    "vendor": "Burton",

    "product_type": "Snowboard",

    "tags": [

      "Barnes & Noble",

      "John's Fav",

      "Big Air"

    ]

  }

}

 

Second Method :

 

Also I have tried a second method where I was passing my <access_token> in header using X-Shopify-Access-Token.

In both the cases I am getting the response as:

 

<html>

<body>

   <noscript>

<a

         href="https://app.shopify.">Continue</a>

</noscript>

 

<script type="text/javascript">

window.location = "https:\/\/app.shopify.com\/services\/login\/identity?destination_uuid=b37e8a73-1443-468e-9515-ff1e82cfab99\u0026enforce_merge=false\u0026merge_ignore_postponed=false\u0026prompt=merge\u0026return_to=https%3A%2F%2Fa%2Fservices%2Flogin%2Fidentity_callback%3Ffrom_signup%3Dfalse%26locale%3Den%26shop_name%3Ddecryptstore%26state%3D61msD8WfwIq7frFE92EuQoV_BbX-w-y8djyrDFC6DypjvlLXjqE4h2RdxujGxlFDiprATJYMito4HD6Rrc_kXnTLq2T4-CIZzcTe2FZcnzK8qvSZyLtwh8fv6etYASpiH1u903Lq095TKyn_PuuRIGry1vf8gKYAVoeSB7Rs6x1k1DZdp-gWwVg0400bG--lZlLtg0OzxowPSWGEFFzstcRBNct_XAq8bQh207meuBU%253D\u0026ui_locales=en\u0026ux=shop";

</script>

</body>

</html>

 

 

I have also tried the post request for adding script tag.My post request was:

 

https://<Api_key>:<access_token>@<store_name>.myshopify.

 

pramas:

 

{

  "script_tag": {

    "event": "onload",

    "src": "<hosted_js_file>"

  }

}

 

I have tried putting "Content-Type: application/json" But I got same response.

Can someone please help me with this.

 

 

Thanks

Varsha Mundhe.

1 Like
Highlighted
Shopify Partner
1777 211 370

This is an accepted solution.

Is your access token a Storefront API or Admin API token? If it's an Admin API token you can pass it in X-Shopify-Access-Token header, but the URL you are posting should be of the following format:

https://...myshopify.com/admin/api/2020-01/products.json
Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
1 Like
Highlighted
Tourist
3 0 2

Thanks a lot for your help. Its working now.

0 Likes
Highlighted
Excursionist
20 2 2

I have the same issue as you.

 

Would you be able to clarify what you did in the end?

 

What did your URL look like?

What value did you use for the "X-Shopify-Access-Token"?

 

Thanks

0 Likes
Highlighted
Shopify Partner
1777 211 370

@Ruben00001 what is the exact URL you are calling and what specifically you are trying to achieve?

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
Excursionist
20 2 2

Hi @Visely-Team. I'm trying to POST a product from a website.

 

My URL is in the format:

https://{{API key}}:{{password}}@{{store-name}}.myshopify.com/admin/api/2020-01/products.json

 with credentials from the Admin API with permissions to read and write products.

 

My request has the same body as above.

0 Likes
Highlighted
Shopify Partner
1777 211 370

@Ruben00001 can you try to execute the same request from CURL or Postman?

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
Excursionist
20 2 2

@Visely-Team apologies I wasn't clear. I have been using Postman (but intend to do the same from a website).

0 Likes
Highlighted
Shopify Partner
1777 211 370

Are you using Postman app or an extension that works in a browser?

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
Excursionist
20 2 2

@Visely-Team The app.

0 Likes