Skip to content

Instantly share code, notes, and snippets.

@bwghughes
Created June 3, 2016 08:55
Show Gist options
  • Save bwghughes/c98b52088c3733eed8f9c99581d2fc14 to your computer and use it in GitHub Desktop.
Save bwghughes/c98b52088c3733eed8f9c99581d2fc14 to your computer and use it in GitHub Desktop.
Problem with POST'ing BillExpenseItems
import os
import json
import requests
import logging
logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)
url = "http://0ba03adb.ngrok.io/api.rsc/BillExpenseItems"
body = {
"ExpenseLineId": "21",
"ExpenseAccountId": "6001",
"ExpenseAmount": "10.00",
"VendorID": "800002CA-1464931068",
}
headers = {"Content-Type": "application/json",
"x-cdata-authtoken": os.getenv('CDATA_TOKEN')}
resp = requests.post(url, json.dumps(body), headers=headers)
log.info(resp.json())
log.info(resp.status_code)
Returns:
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 0ba03adb.ngrok.io
INFO:__main__:{'error': {'message': 'Required field Vendor not specified.', 'code': 'ExecuteOData'}}
INFO:__main__:400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment