This repository was archived by the owner on Apr 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 190
This repository was archived by the owner on Apr 29, 2022. It is now read-only.
Create a Quick Expense with an Image with '500 Error' #2239
Copy link
Copy link
Open
Description
It could be used curl to Create a Quick Expense with an Image(create-quick-expense-image) , but when it was executed with python, there was a "500 - Internal Server Error" problem.
I also tried to save file 'Image_1.jpg' as a Base64 encoded image, it was also "500 - Internal Server Error".
Is there any thing wrong with the format or endpoint?
● curl command:OK
curl -X POST \
https://us.api.concursolutions.com/quickexpense/v4/users/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/context/TRAVELER/quickexpenses/image \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: multipart/form-data' \
-H 'concur-correlationid: quick-expense-with-image' \
-H 'content-type: multipart/form-data' \
-F fileContent=@/Users/Downloads/Image_1.jpg \
-F 'quickExpenseRequest={
"expenseTypeId": "JPYPTRAN",
"transactionAmount": {
"currencyCode": "USD",
"value": 99.05
},
"transactionDate": "2020-02-02"
}'
response result:
{"quickExpenseIdUri":"https://seapr1qes.concurasp.com/quickexpense/v4/users/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/context/TRAVELER/quickexpenses/33585510B733F3429F975D4E81B1AFFC"}
● python code:500 - Internal Server Error
import requests
import time
import json
url = "https://us.api.concursolutions.com/quickexpense/v4/users/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/context/TRAVELER/quickexpenses/image"
headers = {
'Authorization': 'Bearer {access_token}',
'Content-Type': 'multipart/form-data',
'concur-correlationid': 'quick-expense-with-image',
'content-type': 'multipart/form-data'}
files = {
'fileContent': open('/Users/Downloads/Image_1.jpg', 'rb'),
'quickExpenseRequest': (None, json.dumps({"expenseTypeId": "JPYPTRAN",
"transactionAmount": {"currencyCode": "USD", "value": 99.05},
"transactionDate": "2020-02-02"})}
response = requests.post(url, headers=headers, files=files)
if response.ok:
print('Successfully created quick expense with image.')
else:
print('status_code: ', response.status_code)
print('text: ', response.text)
print('Failed to create quick expense with image.')
response result:
status_code: 500
text: {"timestamp":"2020-02-03T05:23:52.473+0000","httpStatus":"500 - Internal Server Error","errorMessage":"Internal server error. Please contact system administrator.","errorId":null,"path":"/quickexpense/v4/users/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/context/TRAVELER/quickexpenses/image"}
Failed to create quick expense with image.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels