Last active
April 21, 2023 15:05
-
-
Save mrizwan47/d2e4920856d1e039b26bf9d28fd76393 to your computer and use it in GitHub Desktop.
ShipHero GraphQL API to add Webhook Listener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests, json | |
username = "email@domain.com" | |
password = "YOURPASSWORDHERE" | |
webhook = "https://yoursite.com/?shiphero-webhook=819284691" | |
shop_name = "ShopName" | |
# Authenticate | |
auth = requests.post("https://public-api.shiphero.com/auth/token", json={ | |
"username": username, | |
"password": password | |
}) | |
access_token = auth.json()['access_token'] | |
refresh_token = auth.json()['refresh_token'] | |
headers = {"Authorization": "Bearer {}".format(access_token)} | |
add_wh = requests.post("https://public-api.shiphero.com/graphql", headers=headers, json={'query': ''' | |
mutation { | |
webhook_create( | |
data: { | |
name: "Shipment Update" | |
url: webhook_url | |
shop_name: shop_name | |
} | |
) { | |
request_id | |
complexity | |
webhook { | |
shared_signature_secret | |
} | |
} | |
} | |
'''}) | |
print(json.dumps(add_wh.json(), indent=4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment