Reply
Member
Posts: 8
Registered: ‎12-06-2013

Java ARB Sandbox 400 Invalid URL error

Getting this response when I try to post a cancel using the JAVA ARB API in the Sanbox but it works fine production....

 

<HTML><HEAD>
<TITLE>Invalid URL</TITLE>
</HEAD><BODY>
<H1>Invalid URL</H1>
The requested URL "&#47;xml&#47;v1&#47;request&#46;api", is invalid.<p>
Reference&#32;&#35;9&#46;26f7f648&#46;1430961437&#46;1721bea6
</BODY></HTML>

 

 

 

End point is: https://apitest.authorize.net/xml/v1/request.api

 

Request is:

 

<?xml version="1.0"?>
<ARBCancelSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>xxxx</name>
<transactionKey>xxxx</transactionKey>
</merchantAuthentication>
<subscriptionId>2399775</subscriptionId>
</ARBCancelSubscriptionRequest>

 

 

Could this be related to the SSL key upgrade? 

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Java ARB Sandbox 400 Invalid URL error

Can you go to the https://apitest.authorize.net/xml/v1/request.api on a web browser on the pc/server that you are trying to run the sandbox code?

Member
Posts: 8
Registered: ‎12-06-2013

Re: Java ARB Sandbox 400 Invalid URL error

 
Here's what I get back when I hit this URL:
 
-<ErrorResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" -xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
-<messages>
-<resultCode>Error</resultCode>
-<message>
-<code>E00002</code>
-<text>The content-type specified is not supported.</text>
-</message>
-</messages>
-</ErrorResponse>
Member
Posts: 8
Registered: ‎12-06-2013

Re: Java ARB Sandbox 400 Invalid URL error

I don't see any SSL errors on the browser. I see the lock.

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Java ARB Sandbox 400 Invalid URL error

The error have the url encoded in HTML?

The requested URL "&#47;xml&#47;v1&#47;request&#46;api", is invalid.

 

instead of

The requested URL "/xml/v1/request.api", is invalid.

Member
Posts: 8
Registered: ‎12-06-2013

Re: Java ARB Sandbox 400 Invalid URL error

Thats the response coming back from your servers. I'm using the JAVA ARB and have changed nothing except adding logging.

 

If I switch the url to https://api.authorize.net/xml/v1/request.api

 

Everything works fine.

 

 

 

 

public BasicXmlDocument sendRequest(BasicXmlDocument request_document){
BasicXmlDocument response = null;
result_code = null;
messages.clear();

String in_response = http_util.postUrl(request_document.dump());

System.out.println("Response-XML::\n" + request_document.dump());

if(in_response == null) return null;

int mark = in_response.indexOf("<?xml");
if(mark == -1){
System.out.println("Invalid response");
System.out.println(in_response);
return null;
}
response = new BasicXmlDocument();

response.parseString(in_response.substring(mark,in_response.length()));
// System.out.println("Response-XML::\n" + response.dump());
if(response.IsAccessible() == false){
System.out.println("Invalid response");
System.out.println(in_response);
return null;
}

/*
try{
FileOutputStream fos = new FileOutputStream("out.xml",true);
fos.write(in_response.getBytes());
}
catch(Exception e){
System.out.println(e);
}
*/
current_response = response;
importResponseMessages();
return response;
}

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Java ARB Sandbox 400 Invalid URL error

[ Edited ]

Might need to use some http traffic logger like fiddler to see what you sending exactly, and what was the response are.

the XML url shouldn't be response a HTML page. something is not working, could be a bad request. are you setting the xml type / request length?

 

Member
Posts: 8
Registered: ‎12-06-2013

Re: Java ARB Sandbox 400 Invalid URL error

I'm using the JAVA ARB API, so the API code is setting those flags and as far as I can tell it looks correct. Is anybody else having trouble with the java api?

 

Here is the method for the API.

 

private String doSocketTransfer(Socket socket, String path, String post_data) throws IOException {
String line;
StringBuffer sb = new StringBuffer();
String method = "GET";
if (post_data != null)
method = "POST";
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out.write(method + " " + path + " HTTP/1.0\n");
if (post_data != null) {
out.write("Content-Length: " + Integer.toString(post_data.length()) + "\n");
out.write("Content-Type: text/xml; charset=\"utf-8\"\n");
}
out.write("\n");
if (post_data != null) {
out.write(post_data);
}
out.flush();

while ((line = in.readLine()) != null) {
sb.append(line + "\r\n");
}
out.close();
in.close();
socket.close();
return sb.toString();
}

Member
Posts: 6
Registered: ‎06-23-2015

Re: Java ARB Sandbox 400 Invalid URL error

Is there a solution for this issue? We are running into this same issue on  Sandbox testing for ARB.

 

We made sure the below things:

 

1. Our keystore has GeoTrust_Global_CA
2. Uses SHA-256
3. Solution does not connect directly to auth.net using ip address
4. Not blocking external connections through firewall

 

Is there anything else to check? Below are some other things tried:

 

1. Set Java to not DNS cache by editing the java.security file and setting "networkaddress.cache.ttl" to 0 instead of chaching forever by default. Tried this to avoid java connecting to a static ip as Auth.net seems to have switched to serving from CDN instead of from static ip's.

 

2. Restarted JVM with parameter to not cache "-Dsun.net.inetaddr.ttl=10"

 

3. Used 8.8.8.8 in resolv.conf to have Google resolve DNS.

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Java ARB Sandbox 400 Invalid URL error

Do you get the 400 error when you put the url in a browser windows?