We are getting below error while execute this statement
request.GetRequestStream().Write(requestStringBytes
The remote server returned an error: (400) Bad Request.
Solved! Go to Solution
While execute the getrequeststream statement we are getting below error <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid URL</h2>
<hr><p>HTTP Error 400. The request URL is invalid.</p>
</BODY></HTML>
Header details
------------------
{Authorization: Basic SDNOSVJHQ0NEQVowQ0VKUDg4S0oyMTFZUUxCV2lQZVo5dTBBaVpwWHYzZW1fd05oazpKUDdoR1dORkZjRjNIaEtPNUlYMQ==
ex-correlation-id: 7AQ76C44W95P_SC
Content-Type: application/json
Accept: application/json
}
We are getting
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid URL</h2>
<hr><p>HTTP Error 400. The request URL is invalid.</p>
</BODY></HTML>
in Merchant search
Hey @rasith,
The cause and resolution of the Bad Request 400 error could be due to a variety of reasons.
Check for the following:
Or
Or
If the error persists, please provide the following information:
1. End Point
2. Request Header
3. Request Body
4. Response Header (include the x-correlation-id)
5. Response Body
Using SoapUI, you can find the x-correlation-id in the Raw Tab of the response header.
Here's a link to the Visa Developer Error Codes which will be useful if you run into errors - https://developer.visa.com/pages/visa-developer-error-codes
Thanks Diana for your kind reply. We have checked what you asked and comments are below;
Request URL is below
https://sandbox.api.visa.com/merchantsearch/v1/search
there is no white space and query parameters.
We are not using token type. Please kindly confirm us this end point needs to Two Way SSL. Because we created client side p12 certificate and key attached in configuration file.
Request Header
{Authorization: Basic SDNOSVJHQ0NEQVowQ0VKUDg4S0oyMTFZUUxCV2lQZVo5dTBBaVpwWHYzZW1fd05oazpKUDdoR1dORkZjRjNIaEtPNUlYMQ==
ex-correlation-id: 46L2MPH2645T_SC
}
Request Body
{"header": {"messageDateTime": "2019-09-15T06:02:59.340","requestMessageId": "CDISI_GMR_001","startIndex": "1"},"searchAttrList": {"merchantName": "ALOHA CAFE","merchantStreetAddress": "410 E 2ND ST","merchantCity": "LOS ANGELES","merchantState": "CA","merchantPostalCode": "90012","merchantCountryCode": "840","visaMerchantId": "11687107","visaStoreId": "125861096","businessRegistrationId": "196007747","acquirerCardAcceptorId": "191642760469222","acquiringBin": "486168"},"responseAttrList": ["GNSTANDARD"],"searchOptions": {"maxRecords": "2","matchIndicators": "true","matchScore": "true"}}
Using Post method.
We did not get any response details because if executing the statement of request.GetRequestStream() immediately it moved to exception.
We are using .Net to make connection and get response from API.
Please kindly check this and let us guide how to proceed further to solve this issue.
Thanks
Rasith
Hey @rasith,
Merchant Search uses Two-Way SSL.
Make sure to follow the guide step by step and in sequence to get a successful response. I've provided steps on how to configure Soap UI for a successful response and I've included example screenshots. Please also see the successful SOAP UI setup I have in the attachment XML file for Merchant Search and make sure to use your own VDP project credentials (username and password) and JKS file.
To access your project credentials, please login to your VDP account > My Account > Dashboard > project app > Credentials
Also, please double check the SSL settings and make sure the keystore has all the necessary certificates imported. To start, this error usually occurs when your certificates are not sent.
· Keystore is not setup. Certificates are not in the keystore:
○ For java keystore (jks) run keytool command and verify all the certificates have been imported on the keystore
· keytool -list -v -keystore keystore.jks
○ For a p12 execute the following openssl command:
· openssl pkcs12 -info -in keyStore.p12
· In SOAPUI check File->Settings->SSL Settings and make sure the KeyStore and KeyStore Password are populated in Soap UI
· Check SSL Info Tab in SOAP UI Response and verify you have a Local Certificate 1, Local Certificate 2 followed by Peer Certificate 1 and Peer Certificate 2
· In addition to that, if you are using SOAP UI, please make sure to select "Authenticate pre-emptively" under "Auth (Basic)" tab. Also, please double check in the request raw tab that the "Authentication Basic" is present.
· Check request header and make sure Authorization: Basic has been populated with the base64 encoded username and password:
Please follow the Working with Visa APIs guide and read the Two-Way SSL (Mutual Authentication) guide: https://developer.visa.com/pages/working-with-visa-apis/two-way-ssl
Furthermore, please make sure you are using valid Test Data from your project app.
If the issue persists, please provide more information on the error you have received for further investigation. Please send the response request of the error received, screenshot and the Correlation ID. Please let us know if you have other questions.
Successful JSON Request:
{
"searchAttrList": {
"merchantName": "STARBUCKS",
"merchantCity": "SAN FRANCISCO",
"merchantState": "CA",
"merchantPostalCode": "94127",
"merchantCountryCode": "840"
},
"responseAttrList": [
"GNSTANDARD"
],
"searchOptions": {
"wildCard": [
"merchantName"
],
"maxRecords": "5",
"matchIndicators": "true",
"matchScore": "true",
"proximity": [
"merchantName"
]
},
"header": {
"requestMessageId": "Request_001",
"startIndex": "0",
"messageDateTime": "2019-08-20T18:18:40.903"
}
}
Hey @rasith,
Here's a screenshot of the 200 OK I got from Soap UI for Merchant Search.
Hey @rasith,
Instead of using Soap UI, you can also start testing with the VDP Playground application, which is downloadable from your VDP project under the "Assets" section.
The VDP Playground is an application that makes testing VDP APIs easy and quick and it creates the JKS file for you quickly.
I got a successful response using the VDP Playground, refer to the screenshot below. Please note, to create the JKS file just browse for your public key (cert.pem) and private key and click on the JKS button. After you click on the JKS button a message will appear saying that your JKS file is created. Also, make sure to enter your credentials, host, port and EndPoint. You will also need to enable the Proxy.
Thanks Diana for your reply,
We tried with use of Visa Developer Center Playground. We gave all details from our dashboard. We have attached the Public and private keys.
We have given the .p12 certificate and password but not given jks. if we are running that we are getting below error. We are accessing this API from middle East region(United Arab Emirates). Is it possible to access this?
Error:
This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server (sandbox.api.visa.com)
Hey @rasith,
Can you please explain what you mean when you say "but not given jks"? You will only need to input your cert.pem (public key) and private key. After you input this into VDP, you will have to click on the "JKS" button, enter a password (e.g. Visa123) then enter the name of the JKS (e.g. clientkeystore) then a keystore will be created in the folder that you have saved the cert.pem and private key in. Make sure you create a folder on your local machine to put your cert.pem and private key in.
Then you will also need to input your User ID and Password.
If the error persists, please provide the following information:
1. End Point
2. Request Header
3. Request Body
4. Response Header (include the x-correlation-id)
5. Response Body
Using SoapUI, you can find the x-correlation-id in the Raw Tab of the response header.