cancel
Showing results for 
Search instead for 
Did you mean: 

POST API to send file - Mastercard API

Jian_JunSeow
Level 2

Hi all,

I am looking for help with using POST method in Web API Services with Single File to perform the Mastercard API below.
How should I include the rest of the required details in the Body (ie amount, chargebackType, etc)?

Common Header: Content-Type has value application/json
Request Body Content: Single File
File Parameter Name: File

I have also loaded the pdf file into a binary data type (File) in blue prism using the function LoadBinaryFile()

API Documentation link:
https://developer.mastercard.com/mastercom/documentation/api-reference/v6-reference/

Request URL:
https://api.mastercard.com/mastercom/v6/claims/{claim-id}/chargebacks

Body:

{
"amount": "100.00",
"chargebackType": "CHARGEBACK",
"currency": "USD",
"documentIndicator": "true",
"reasonCode": "4853",
"credPostedAsPurchase": false,
"isPartialChargeback": false,
"messageText": "This is a test message text",
"settlementDate": "2021-09-22",
"localTax1IVA": "0.60",
"installmentFee": 1.2,
"editExclusionCode": "BO",
"refundNotReceivedIndicator": "true",
"includeCurrencyConversionAssessmentCCA": "true",
"fileAttachment": {
"filename": "testimage111111.pdf",
"file": "This is an image file stored in a base64 encoded string"
}
}

2 REPLIES 2

Hi Jian Jun,

Since the whole request body is formatted in JSON, use the Body Content as "Template" instead of "Single File". Use the Base64 encoder from DX https://digitalexchange.blueprism.com/dx/entry/3439/solution/base64encoder-2 to convert the binary file to Base64 string that you can then include in the JSON request.

Hi Jian,

Yes as Shashank said you will need to include the file as a BASE 64 encoded file. If you look at the Model tab of the call this is the description mastercard give.

fileAttachment DocumentStructure

CONDITIONAL: Unless specified as REQUIRED, fileAttachment object is OPTIONAL. When fileAttachment is provided, then fileName and file parameters are required. The base64 encoded string must represent a ZIP, JPG, TIFF, or PDF file. Please note: ZIP files may contain JPG, TIFF or PDF files.


The parameter should be fileName with a capital N, as well as file. You can use the below encoder if this is going to be a variable parameter in your process and for testing use the following site for a proof of concept: https://www.base64encode.org/ ;

I can also see you've used the data given as an example of 2021-09-22, however this won't work as it says above it "The date may not be prior to the current date or beyond 90 days from the current date." so change this to 2022-05-30 for your testing purposes.

Hope this helps, best regards,

Ronan
Ronan Considine Senior Business Analyst Blue Prism