Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.
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

@hjtso

Description

@hjtso

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions