Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SalesforceMalformedRequest: Malformed request
- https://my_org.my.salesforce.com/services/data/v38.0/sobjects/Attachment/.
- Response content: [{
- 'message': "Json Deserialization failed on token 'null' and has left off in the middle of parsing a row. Will go to end of row to begin parsing the next row",
- 'errorCode': 'INVALID_FIELD'}]
- from simple_salesforce import Salesforce
- from base64 import b64encode
- import json
- userName = 'my_username@test.com'
- password = 'mypw'
- securityToken = 'mytoken'
- svc = Salesforce(username=userName, password=password, security_token=securityToken)
- ENCODING = 'utf-8'
- name = 'test.txt'
- parent_id = '5001I000006rNenQAE'
- with open(name, 'rb') as open_file:
- byte_content = open_file.read()
- base64_bytes = b64encode(byte_content)
- base64_string = base64_bytes.decode(ENCODING)
- json_data = json.dumps({
- 'ParentId' : parent_id,
- 'Name' : name,
- 'Body' : base64_string
- })
- result = svc.Attachment.create(json_data)
- print(result)
- svc.Attachment.create({ 'ParentId': parent_id, 'Name': name, 'Body': base64_string })
Add Comment
Please, Sign In to add comment