404 Error in accessing https URL - Java , but working fine with POSTMAN or SOAPUI

Edit on 21st Nov : I have tried in accessing the URL directly using browser, it gives me the same 404 error response. But while checking in POSTMAN - code , i could see the call goes as below. So can someone please let me know how to send the call in sameway? thanks

POST /api/test/PW/authentication/user HTTP/1.1

Host: www.hostname.com X-API-Key: saksj82kqjsak290d

cache-control: no-cache

Postman-Token: 2b7fl871-195a-4782-9000-6ce269242704

Content-Type: multipart/form-data;boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name="credential"

user123

Content-Disposition: form-data; name="password"

pass123 ------WebKitFormBoundary7MA4YWxkTrZu0gW--

Original Message : I have an issue while fetching token from a https Rest APi using Java code. Request URL : https://www.hostname.com/api/test/PW/authentication/user Curl : curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --header 'ApiKey: saksj82kqjsak290d -d 'userid=user123&password=pass123' 'https://www.hostname.com/api/test/PW/authentication/user' Method : POST

Once i send Post reqyest i will get the Token in Header values in JSON format. But while pinging the server i am getting 404 rsponse from Java. But with POSTMAN tool, i am getting the response as 200 with proper token in response header data.

Note : i have changed the URL here to some dummy.

So far i have tried as below and not sure where i have gone wrong.

                    import java.net.*;
                import java.io.*;
                import java.util.*;
                import java.io.BufferedReader;
                import java.io.DataOutputStream;
                import java.io.IOException;
                import java.io.InputStreamReader;
                import java.io.UnsupportedEncodingException;
                import java.net.CookieHandler;
                import java.net.CookieManager;

                import java.net.URL;
                import java.net.URLEncoder;
                import java.util.ArrayList;
                import java.util.List;

                import java.util.Set;
                import java.net.HttpuConnection;

                import javax.net.ssl.HttpsuConnection;
                import java.lang.annotation.Retention;
                import java.net.MalformedURLException;

                public class Tokenhttps {
                    public static void main(String[] args) throws MalformedURLException {

                        int code;

                        String httpsurl = "https://www.hostname.com/api/test/PW/authentication/user";

                        String KeytoPass = "saksj82kqjsak290d";

                        try{
                              URL httpurl = new URL(httpsurl);
                              HttpuConnection uConnect = (HttpuConnection) httpurl.openConnection();

                            //Set header
                              uConnect.setDoOutput(true);
                              uConnect.setRequestMethod("POST");
                              urlConnect.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
                              uConnect.setRequestProperty("Accept", "application/json");
                              uConnect.setRequestProperty("ApiKey", KeytoPass);

                            //Set body
                              String bodydata ="{\"userid\":\"user123\",\"password\":\"pass123\"}";

                            //POST
                            DataOutputStream  dos = new DataOutputStream (uConnect.getOutputStream ());
                            dos.write(bodydata.getBytes());
                            dos.flush();

                            // Read the response.
                            InputStreamReader isr = null;
                            code = uConnect.getResponseCode();
                          System.out.println("responseCode:" + code );
                            if (code == 200) {
                                System.out.println("Connection is Success" );
                               isr = new InputStreamReader(uConnect.getInputStream());
                             //Print Header Fields
                                  System.out.println("HeaderValues :"+uConnect.getHeaderFields ());
                                                } 
                           else {
                               isr = new InputStreamReader(uConnect.getErrorStream());
                            }
                        }

                         catch(Exception errormsg){
                          System.out.println("Error: " +errormsg);
                        }   
                    }
                }

In the Java code, the bodydata is json but in the curl command you are passing in userid and password formatted as x-www-form-urlencoded. Most likely, the service is expecting the later so it isn't getting the proper values when you pass it in as the former.

Getting 404 Error While Trying to GET data from API using , But While I am trying to GET any data from any API (Say for and Run http://​localhost:8080/openmrs/ which works properly. Problem accessing /openmrs/​activelisttype. https://openmrs.gitbooks.io/developer-manual/content/en/ API end using POSTMAN or RESTclient I am getting 404 Not found Error. No luck, i have tried that as well, but same reponse code : 404. I am passing as per the CURL , but unable to get succeed with the same. But SOAP UI and POSTMan are working fine. Also not sure because of httpS url it requires some additionalcode as i am not sure of it. – Ven Nov 20 '18 at 15:19

Try setting the content-type property in your java code. The server you're hitting might need that header to process the parameters you're passing with the POST request.

Solved: API is not working using soapUI but is fine when A , Solved: Hi, I just started using soapUI for testing and everything was fine so far on my API calls except for one. API is not working using soapUI but is fine when API is called using Postman ERROR:Exception in request: java.net. According to that,one of the reason cab be that url might be https not http. Technically, an Error 404 is a client-side error, implying that the error is your mistake, either because you typed the URL incorrectly or the page has been moved or removed from the website and you should have known. Another possibility is if a website has moved a page or resource but did so without redirecting the old URL to the new one.

It has worked with below change :

String bodaydata= "credential=user123&password=pass123";

POST Web API returning 401 with Postman (and with some apps , POST Web API returning 401 with Postman (and with some apps) Within Appian and using cURL, SoapUI, and Advanced REST Client (Chrome), (​POST) and consume it from some different type of systems such as Java, . So I asked our Bluemix guys to explicitly add the Origin: {Appian URL} and the app now works. Note: Make sure to disable the preemptive authentication before accessing the service via NTLM. For NTLM 2, provide your username as DOMAIN\USERNAME or \USERNAME. Pre-emptive auth-Allows to enable the preemptive authentication for this specific request or command the request to use global SoapUI preferences.

How to troubleshoot a GET request that is not working with RA but , I have a simple GET request that is working well with Postman client. However same request is not working at all with REST-Assured. Burp proxy for https it suddenly starts to work, when I turn it off, again fails But I got error and these 2 are not shown as being added to the list of DEBUG (Info): url  On the WS-I Compliance tab, you can validate your web service against the WS-I Basic Profile (see below).. Validate the WSDL against the WS-I Basic Profile. Since the initial creation of WSDL and SOAP, a multitude of standards have been created and embodied in the Web Services domain, making it hard to agree on exactly how these standards should be used in a Web Service Context.

Error Response: Use status code 404 for "resource not found" · Issue , The "error response" section currently states: HTTP 400: not_found - The post with the requested URL was not found Both RFC 1945 (HTTP/1.0) and RFC 2068 Creating will work fine, which will make the client consider that the endpoint actually exists. 404: https://tools.ietf.org/html/rfc7231#section-6.5.4  The SOAP Service Mocking functionality in SoapUI lets you create a standards compliant simulation of a WSDL based service just from its WSDL contract, which in soapUI is called a “MockService”. This can be run either directly from inside soapUI, with the included command-line runner, or even with a standard servlet container.

SOAP Requests with Postman - Kris Sparks, Postman is a clean, easy-to-use REST client, but it also works well for the following URL and endpoint: of https://www.robot-lending.com/quick-loan SOAPAction header we may get an error: <faultstring>no SOAPAction header! Get unlimited access to the best stories on Medium — and support writers while you're at it. I am connecting to a SOAP webservice that requires SSL authentication. I (the web service client) have a .pfx file and provided the public certificate for that file to the company whose web service I am accessing. I am able to send a successful SOAP request to their web service through SoapUI (after configuring SoapUI to use the .pfx).

Comments
  • Any inputs please ?
  • I am sending x-www-form-urlencoded in header only, just updated with the same. But User id and password i am sending in JSON format with curl braces. Still no luck. Can you please eloberate "Most likely, the service is expecting the later so it isn't getting the proper values when you pass it in as the former"
  • It looks like you already figured it out. When you set the content type to x-www-form-urlencoded, you are telling the server to expect the request data to be in a certain format. In this case, a format similar to how query strings get formatted. Originally, you sent the request data in a different format which was encoded as JSON. Because the server wasn't expecting that format, it didn't get the data you were sending correctly.
  • thanks for explantion, but actually after correcting the credentials in different format as specified below, the content type to x-www-form-urlencoded is not really a required to send as I am already sending the to accept the format as application/json. However thank you very much for your inputs.
  • No luck, i have tried that as well, but same reponse code : 404. I am passing as per the CURL , but unable to get succeed with the same. But SOAP UI and POSTMan are working fine. Also not sure because of httpS url it requires some additionalcode as i am not sure of it.