Call checkoutDiscountCodeApplyV2 mutation

kiarze
New Member
1 0 0

Hi all,

I'm trying to develop an external app that updates the checkout using the storefront api.

For a first test I'm testing the service calls manually to see what data flows and test the API generically.

I'm able to create a PriceRule, a DiscountCode and now I would want to update a checkout with the mutation checkoutDiscountCodeApplyV2.

Using the GraphQL explorer on the admin page I'm having the following error:
"Field 'checkoutDiscountCodeApplyV2' doesn't exist on type 'Mutation'"

I'm using the sample given on the API documentation on this:

mutation checkoutDiscountCodeApplyV2($discountCode: String!, $checkoutId: ID!) {
  checkoutDiscountCodeApplyV2(discountCode: $discountCode, checkoutId: $checkoutId) {
    checkout {
      id
    }
    checkoutUserErrors {
      code
      field
      message
    }
  }
}

with the required variables assigned.

Changed approach and tried to use Postman. Afaik, I need to get a specific access token doing a post to a service, but it replies my with an auth page.

kiarze_0-1620139450692.png

 

What should I do to test this last mutation manually?
I've Shopify Plus, and I have an app where I can get an access token and do some queries, I have not yet used this mutation and I was trying to do some testing before starting the development.

Thank you

0 Likes
Kevin_A
Shopify Staff
Shopify Staff
290 35 46

Hey @kiarze 

The mutation you are using is specific to the Storefront API, but it appears you are trying to run it against the Admin API. Check out this doc for getting started using the Storefront API.

Kevin_A | 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

0 Likes