Re: REST Api 401 Authorized/Authentication Failed error

VSDylan
Newbie

REST Api 401 Authorized/Authentication Failed error

Hi there,

 

I am making this post as I have been integrating the CyberSource REST Api into application for the purpose of posting transactions/payments and I have been stuck at this authentication errror.

 

To me, it looks like the headers and JSON body are correct in my request, and I am unsure why I am seeing this error.

 

While the headers and their values are generated in my C# code, I have brought all the request information into Postman and am seeing the same error response as I was seeing when the request was being created in the code.

 

Here is the error I see in Postman:

 

{
    "response": {
        "rmsg""Authentication Failed"
    }
}
 
Note: The status is 401 Unauthorized.
 
Here is the information for the request, is there anything below that looks incorrect that could be causing this issue?
 
 

 

POST /pts/v2/payments/ HTTP/1.1
Host: apitest.cybersource.com
Date: Thu, 01 Oct 2020 15:45:02 GMT
v-c-merchant-id: testvanillasoft
Digest: SHA-256=FJzl6g1B678u9g5g/62qXJB+NEXckgHI/oHhrkgJB9M=
Signature: {keyid="0939fb9a-1031-4e40-9736-08f161238fd9", algorithm="HmacSHA256", headers="host date (request-target) digest v-c-merchant-id", signature="zkZ5yEC3lMd/GMeRnV7ADIWMW66zLnxOjgJTOQJywnM="}
Content-Type: application/json

{
    "paymentInformation": {
        "card": {
            "number": "4111 1111 1111 1111",
            "expirationMonth": "12",
            "expirationYear": "2021"
        },
        "fluidData": {
            "descriptor": "",
            "value": ""
        }
    },
    "orderInformation": {
        "amountDetails": {
            "totalAmount": 12,
            "currency": "USD"
        },
        "billTo": {
            "firstName": "Winonah",
            "lastName": "Swinnard",
            "address1": "36 Anzinger Court",
            "locality": "West End",
            "administrativeArea": "BC",
            "postalCode": "B4Z7B3",
            "country": "CA",
            "email": "wswinnardnw@twitpic.com",
            "phoneNumber": ""
        }
    }
}

 

 

I appreciate any help with this.

 

Thanks,


Dylan

2 REPLIES 2
VSDylan
Newbie

Re: REST Api 401 Authorized/Authentication Failed error

I was able to resolve this on my own. In case someone else runs into this issue, there seemed to be an issue with the way the headers were being added or the way the header values were being generated in my code.

 

I used the following sample code as a reference and was able to resolve the issue: https://github.com/sarn1/example-cybersource-csharp-api-rest/blob/master/rest-sample/rest-sample/Pro...

API_Products
Visa Developer Support Specialist

Re: REST Api 401 Authorized/Authentication Failed error

Hey @VSDylan,

 

Great to hear that you were able to resolve the CyberSource Payments issue on your own. Thanks for sharing your resolution with us and if you run into other issues, let us know and someone will be happy to help.

 

Please note, currently, the only way you can conduct a CyberSource Payments sandbox test is by creating a merchant account directly with CyberSource here: https://developer.cybersource.com 
 

It's also good to know that the CyberSource site provides an easy method to test their account credentials:
 
https://developer.cybersource.com/api/reference/api-reference.html 
 
Here's the sample code links:  https://github.com/CyberSource/cybersource-rest-samples-java/blob/master/src/main/java/samples/payme... 

 




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.