"Expected input credential was not present"

SOLVED
Highlighted
Regular Visitor

"Expected input credential was not present"

I am new to visa api integration. 

Can someone please help with this issue "Expected input credential was not present". 

I have the  authentication username and password added to the request header as well as the x-pay-token.

 

Full error code is

"{\"code\":400,\"body\":\"Client error: `POST https:\\\/\\\/sandbox.api.visa.com\\\/vop\\\/v1\\\/users\\\/enroll` resulted in a `400 Bad Request` response:\\n{\\\"responseStatus\\\":{\\\"status\\\":400,\\\"code\\\":\\\"9124\\\",\\\"severity\\\":\\\"ERROR\\\",\\\"message\\\":\\\"Expected input credential was not present\\\",\\\"}

10 REPLIES 10
Highlighted
New Contributor

Re: "Expected input credential was not present"

It will be easier to respond if you can post a sample of your code (without your credentials and without your keys)

Unless someone here has that experience before.

Highlighted
Regular Contributor

Re: "Expected input credential was not present"

Hi @BH,

Make sure you've downloaded your private key & all certificates for the project to pass them in API call while invocation. You can test the certificates validity first with SoapUI or Visa playground. 

If you're invoking the Visa APIs directly from the sample code, then please create the appropriate keystores. 

Let us know if you're able to resolve the issue & if it persists please respond with the API request parameters.

 

Note: Check out this article on how to set-up Two way SSL. 

 

Thanks

Swarit  

Highlighted
Regular Visitor

Re: "Expected input credential was not present"

Dear all,

I really appreciate your response.

 

Below is the sample code I am trying to use to call the api. The code was extracted from the sample code provided on this platform.

 

<?php

$url = 'https://sandbox.api.visa.com/vop/v1/users/enroll';
$postData = json_decode('{"membershipNumber":"123496","cards":[{"expirationYear":"2020","expirationMonth":"12","nameOnCard":"US-BANK","billingZipCode":"11901","cardNumber":"4111348293334910","ccv2":"775"}],"contacts":[{"countryCode":"1","isPreferred":true,"type":"SMS","isContractVerified":true}],"attributes":[{"name":"test1","value":"test2"}],"referrerId":"45561","externalUserId":"356086","timeZoneId":"Pacific Standard Time","languageId":"en-US","promoCode":"45168","userKey":"9722108549","communityCode":"SANDBOX"}');

$curl = curl_init();
// set timeout, if needed
curl_setopt($curl, CURLOPT_TIMEOUT, 0);
// set connect timeout, if needed
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);

// return the result on success, rather than just true
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, []);

// disable SSL verification, if needed
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_PROXY, '');
curl_setopt($curl, CURLOPT_PROXYPORT, ''); //$this->config->getCurlProxyPort());
curl_setopt($curl, CURLOPT_SSLCERT, ''); //$this->config->getCertificatePath());
curl_setopt($curl, CURLOPT_SSLKEY, ''); //$this->config->getPrivateKey());
curl_setopt($curl, CURLOPT_CAINFO, ''); //$this->config->getCaCertPath());
curl_setopt($curl, CURLOPT_PROXYTYPE, ''); //$this->config->getCurlProxyType());
curl_setopt($curl, CURLOPT_PROXYUSERPWD, ''); //$this->config->getCurlProxyUser() . ':' .$this->config->getCurlProxyPassword());
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
curl_setopt($curl, CURLOPT_URL, $url);

// Set user agent
curl_setopt($curl, CURLOPT_USERAGENT, $this->config->getUserAgent());
curl_setopt($curl, CURLOPT_VERBOSE, 0);

// obtain the HTTP response headers
curl_setopt($curl, CURLOPT_HEADER, 1);

// Make the request
$response = curl_exec($curl);

var_dump($response);

 

 

my concern is that I am not able to get the missing parameters even from my account or from the sample code provided.

 

any help pls. 

Highlighted
Regular Visitor

Re: "Expected input credential was not present"

Hi @swaritsharma 

 

I have the certificate downloaded but there is no ssl cert key.

I have read through some articles online saying it would have to be generated. 

 

Please, can you help with what I need to do in order to generate a valid ssl cert key for the test to go through.

 

Thank you

Highlighted
Regular Contributor

Re: "Expected input credential was not present"

Hi @BH,

 

Follow following steps:

Step 1. You can download the ssl cert key from Account > Dashboard > <your sandbox api project> > Project Certificate & Credentials > Download Certificate.

 

Step 2. After downloading the "cert.pem" & assuming you've downloaded the private key (looks like key_6523cdafsdf-4sdfsdf7-4c4a-a038-f3920b28961f.pem) while creating the project.

You can pass the path for both of the keys in config properties CURLOPT_SSLCERT (=/path/to/cert.pem) &  CURLOPT_SSLKEY(=/path/to/key_6523.....pem) respectively.

 

Let us know if you're able to solve the issue after following these steps.

 

Note: For more info follow this article to configure your ssl keys. 

Highlighted
Regular Visitor

Re: "Expected input credential was not present"

Hi @swaritsharma,

 

I am getting the error below when I make request to enroll user endpoint:

 

string(784) "HTTP/1.1 500 Internal Server Error Server: nginx Date: Tue, 29 Sep 2020 10:41:09 GMT Content-Type: application/json Content-Length: 255 Connection: keep-alive X-SERVED-BY: l73c015 X-CORRELATION-ID: 1601376069_678_361947923_l73c015_VDP_WS X-APP-STATUS: 500 Cache-Control: no-cache, no-store, must-revalidate Pragma: no-cache Expires: 0 ,-1 X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff Strict-Transport-Security: max-age=2592000;includeSubdomains X-Cnection: close {"correlationId":"907f94c4-3b66-4be0-86b1-764e359f454d","responseDateTime":"Tue Sep 29 10:41:09 GMT 2020","responseStatus":{"code":"FAILED","message":"Request failed.","responseStatusDetails":[{"errorCode":"500","errorMessage":"Internal Server Error."}]}}

 

I am also wondering if you could advise on what the value of the proxy params below should be, pls

//curl_setopt($curl, CURLOPT_PROXY, '');
//curl_setopt($curl, CURLOPT_PROXYPORT, '');
// curl_setopt($curl, CURLOPT_PROXYTYPE, '');

 

Thank you

Highlighted
Regular Contributor

Re: "Expected input credential was not present"

Hey @BH ,

Is there an Nginx proxy server between Visa & Api Client?

Highlighted
Regular Visitor

Re: "Expected input credential was not present"

HI @Panamera  and @swaritsharma,

 

Below is the sample curl I am using to call the endpoint.

 

The below code was extracted from the sample code provided in the project.

 

$username = '........';
$password = '.........';
$url = 'https://sandbox.api.visa.com/vop/v1/users/enroll';

$postData = json_decode('', true);

$curl = curl_init();
// set timeout, if needed
curl_setopt($curl, CURLOPT_TIMEOUT, 0);
// set connect timeout, if needed
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);

// return the result on success, rather than just true
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
"Accept" => "application/json",
"Authorization" => "Basic " . base64_encode( $username. ":" .$password),
// "x-pay-token" => getXpayToken($postData, $url, null, $password)
]);

// disable SSL verification, if needed
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
//curl_setopt($curl, CURLOPT_PROXY, '');
//curl_setopt($curl, CURLOPT_PROXYPORT, '');
curl_setopt($curl, CURLOPT_SSLCERT, getcwd().'/rsa/keys/cert.pem');
curl_setopt($curl, CURLOPT_SSLKEY, getcwd().'/rsa/keys/key_42xxxxxxxx.pem'); //$this->config->getPrivateKey());
curl_setopt($curl, CURLOPT_CAINFO, getcwd().'/rsa/keys/DigiCertGlobalRootCA.crt'); //$this->config->getCaCertPath());
// curl_setopt($curl, CURLOPT_CAINFO, getcwd().'/rsa/keys/VDPCA-SBX.pem');
//curl_setopt($curl, CURLOPT_PROXYTYPE, '');
//curl_setopt($curl, CURLOPT_PROXYUSERPWD, $username.":".$password);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");

curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");

curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($postData));
curl_setopt($curl, CURLOPT_URL, $url);

// Set user agent
//curl_setopt($curl, CURLOPT_USERAGENT, $this->config->getUserAgent());
curl_setopt($curl, CURLOPT_VERBOSE, 0);

// obtain the HTTP response headers
curl_setopt($curl, CURLOPT_HEADER, 1);

// Make the request
$response = curl_exec($curl);

print_r($response);

 

 

I look forward to your quick response.

 

Thank you

Highlighted
New Contributor

Re: "Expected input credential was not present"

Weird.. i tested the same code adding :

"stored_credentials": {

"indicator": "1",

"initiation": "M",

"schedule": "U",

"transaction_id”: ”new”

}