Skip to content

Instantly share code, notes, and snippets.

@agritheory
Last active April 30, 2019 15:37
Show Gist options
  • Save agritheory/4e322dec3682741fe745c631eb91fa0b to your computer and use it in GitHub Desktop.
Save agritheory/4e322dec3682741fe745c631eb91fa0b to your computer and use it in GitHub Desktop.
import requests
from base64 import b64encode
import json
def push_po(doc, method):
# additional business logic or other validations
# prune document fields and turn into json
payload = json.loads({"docfield": doc})
api_key, api_secret = frappe.get_value("User", frappe.session.user, ["api_key", "api_secret"])
url = "http://frappe.local:8000**/api/resource/Purchase Order"
headers = {'Authorization': "Basic %s" % b64encode(api_key:api_secret)}
response = requests.request("POST", url, headers=headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment