File uploaded to salesforce empty using python and simple_salesforce -
i'm trying upload file folder object in salesforce using python , simple_salesforce. file uploaded empty. can tell me why , how fix problem? thanks.
import base64 import json simple_salesforce import salesforce username = 'username' password = 'password' securitytoken = 'securitytoken' sf=salesforce(username='username', password='password', security_token='securitytoken', sandbox = true) sessionid = sf.session_id body = "" open("info.txt", "r") f: body = base64.b64encode(f.read()) response = requests.post('https://cs17.my.salesforce.com/services/data/v23.0/sobjects/document/', headers = { 'content-type': 'application/json', 'authorization':'bearer %s' % sessionid}, data = json.dumps({ 'description':'information', 'keywords':'information', 'folderid': '00lg0000000mqykaag', 'name': 'info', 'type':'txt' }) ) print response.text
based on code above, request incomplete. create body value b64encoding iof file wish upload, isn't included in data associated 'body' key.
depending on version of json, may experience problems getting output play nice salesforce. switched json simplejson , worked better me.
Comments
Post a Comment