Could not get a expected Response through a POST request

Viewed 105

I am working this API https://developer-eu.elavon.com/docs/opayo/spec/api-reference-0#operation/createCi.

I faced an issue, when creating card-identifier. I could not get an expected response. The test API is https://pi-test.sagepay.com/api/v1/card-identifiers

To create a Card Identifier, We need a merchantKey to use as a bearerToken and request body is

{ "cardholderName": "Spongebob Squarepants", "cardNumber": "4929000000006", "expiryDate": "0223", "securityCode": "123" }

To create merchantKey use this https://reqbin.com/pzag38mw

To create Card Identifieruse this https://reqbin.com/zkhuuecs

And I added My postamn request here.

My postman http request for create Card Identifier.

curl --location --request POST 'https://pi-test.sagepay.com/api/v1/card-identifiers' \
--header 'Authorization: Bearer E0780245-2701-4748-924A-A1D5A904EB62' \
--header 'Content-Type: application/json' \
--header 'Cookie: AWSALB=o44OLd5fFLrFUD4meQBU0sxMs64iiql4YlDlppQILCFio+6pOo16e+tLu7SaI+F8sDS8CgSrRTwOcMo//ODTGcJGgNSTHPHxrP5hs87mkM1I1Xos3F0hDEoTD4dV; AWSALBCORS=o44OLd5fFLrFUD4meQBU0sxMs64iiql4YlDlppQILCFio+6pOo16e+tLu7SaI+F8sDS8CgSrRTwOcMo//ODTGcJGgNSTHPHxrP5hs87mkM1I1Xos3F0hDEoTD4dV' \
--data-raw '{
  "cardholderName": "Spongebob Squarepants",
  "cardNumber": "4929000000006",
  "expiryDate": "0223",
  "securityCode": "123"

}'

I got this Response

{
    "errors": [
        {
            "description": "Missing mandatory field",
            "property": "cardDetails.cardNumber",
            "clientMessage": "The card number is required",
            "code": 1003
        },
        {
            "description": "Missing mandatory field",
            "property": "cardDetails.cardholderName",
            "clientMessage": "The cardholder name is required",
            "code": 1003
        },
        {
            "description": "Contains invalid value",
            "property": "cardDetails.expiryDate",
            "clientMessage": "The expiry date is invalid",
            "code": 1009
        },
        {
            "description": "Missing mandatory field",
            "property": "cardDetails.expiryDate",
            "clientMessage": "The expiry date is required",
            "code": 1003
        }
    ]
}

But The response sholud be somthing like this:

{
"cardIdentifier": "C6F92981-8C2D-457A-AA1E-16EBCD6D3AC6",
"expiry": "2015-08-11T10:45:16.285Z",
"cardType": "Visa"
}

What is the mistake I did when I sent a post request

1 Answers

Check the method of posting you are using in postman. If you are unsure edit to add a screenshot. Check if you have selected: enter image description here

As if you use another method it may not read it

So once you have set that instead of sending you data as:

{
  "cardholderName": "Spongebob Squarepants",
  "cardNumber": "4929000000006",
  "expiryDate": "0223",
  "securityCode": "123"
}

You should send it as:

{ "cardDetails":
{
    "cardholderName": "Spongebob Squarepants",
    "cardNumber": "4929000000006",
    "expiryDate": "0223",
    "securityCode": "123"
}
}

This is because it is asking the data from under cardDetails Please tick this if it fixed your problem so I know

Related