Python Bulk Operation different from GraphiQL

Solved
Highlighted
New Member
3 1 0

I am trying to run a Bulk Operation using Python requests but there is missing data in the result.

Here is the query:

mutation{
bulkOperationRunQuery(
query:"""
{
customers{
edges{
node{
id
ordersCount
averageOrderAmountV2{
amount
}
totalSpent

orders{
edges{
node{
id
totalPriceSet{
shopMoney{
amount
}
}
lineItems{
edges{
node{
id
name
quantity
}
}
}
}
}
}
}
}
}
}
"""
){
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}

I have tried this query in GraphiQL and it works but when I run the same query using python requests, the only data that is returned is the customer data. I seems to be ignoring the orders completely.

I have even tried querying only the orders which works in GraphiQL but returns a null url using python.

Any ideas on what might be the problem?

0 Likes
Highlighted
Shopify Partner
372 26 77

As I suggested in your PM, try using CURL or Postman to strip down things. Which you already apparently have done, since you said those GraphQL API requests are working  

Why don't you post a snippet of your Python code where the API request is being built and sent? Off the top of my head, a few things to be mindful are:

  • Ensure the body is being handled as raw JSON data.
  • Ensure the Content-Type is defined in the request header as application/json.
  • Ensure the body itself is property formatted.

Although if you're using the shopify_python_api (https://github.com/Shopify/shopify_python_api#graphql), this project hides most of this complexity from the user. Leaving mainly bullet point #3 in play   

0 Likes
Highlighted
New Member
3 1 0

This is an accepted solution.

@Greg_Kujawa Thanks for your response. It turns out that you can only pull orders that were made in the past 60 days unless you request approval from shopify. All of my orders were made over 60 days ago which was why I was unable to see them when trying to run my bulk operation.

0 Likes