Shopify / shopify-app-js

MIT License
265 stars 103 forks source link

How do you create an article #873

Closed 7ynk3r closed 3 months ago

7ynk3r commented 4 months ago

I'm trying to create an article using APIs (any will do) in NodeJS. Can you indicate how to achieve this? The docs don't help much and chatgpt, perplexity nor gemini can help. I'd really appreciate an E2E example. I already have API keys for storefront & admin with all the scopes.

For context,

I tried using cURL

curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-01/articles/authors.json" \
-H "X-Shopify-Access-Token: {access_token}"

without success with all token

{"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}%                                                                                                  

I tried gql

curl -X POST \
  https://{shop}.myshopify.com/admin/api/2024-04/graphql.json \
  -H 'Content-Type: application/json' \
  -H 'X-Shopify-Access-Token: {access_token}' \
  -d '{
    "query": "query {
      products(first: 5) {
        edges {
          node {
            id
            handle
          }
        }
        pageInfo {
          hasNextPage
        }
      }
    }"
  }'

and got

Bad request
7ynk3r commented 4 months ago

If someone else ends up here and there's no answer to my original post, the following works

https://github.com/MONEI/Shopify-api-node

lizkenyon commented 4 months ago

Hi there 👋

In the future questions about how to make API calls in general are best suited for the Shopify Community forums.

For this specific example can you confirm that you are replacing https://your-development-store.myshopify.com with the URL of your store and {access_token} with the access token of your app?

If you want to explore the Shopify Admin and Storefront APIs you may also want to checkout the Graphiql explorer.

github-actions[bot] commented 3 months ago

We are closing this issue because we did not hear back regarding additional details we needed to resolve this issue. If the issue persists and you are able to provide the missing clarification we need, feel free to respond and reopen this issue.

We appreciate your understanding as we try to manage our number of open issues.