• Register
0 votes
67 views

Problem :

I am facing following Error.

Status 1 error, param missing, error because at least one required parameter is missing.

Can anybody tell me the correct status code to give when the parameter is missing from the request? Is 400 the correct one? Or is it 404?

[GET /search?q=ok] => 200 OK

[GET /search] => 400 Bad Request? or 404 Not Found? Or 422 Unprocessable Entity? Others?

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

The correct status code is HTTP 400 - Bad Request.

The HTTP 400 is correct as the user did not send the Required input field.

Why HTTP 422 is incorrect - As the current case is exact match to HTTP 400. So keeping the end user in mind one should not go with not popular response codes if it is not needed.

 

Where can you use HTTP 404:-

1)  If the client requesting url is not present on the server:- Usually it will be taken care by the server team. Developer usually builds nice looking 404 page only rest will be handled by server team

2) If the client requesting path parameter is not present on the server:- If client was looking for an entry with an id and if the application does not have such entry, you must respond back with an HTTP 404 code.

9 7 4
38,600 points

Related questions

0 votes
1 answer 157 views
157 views
Problem: Hi there! I have been learning to program for a long time now and I recently learned inheritance in Java. I wrote the following program for practice: class Institutions { public void print_institutions() { System.out.println("This is an institution"); } } class ... , I have no idea what is causing this error. Can anybody here please clarify the cause of the error and its solution? Thanks!
asked Dec 29, 2020 Code Learner 9.2k points
0 votes
1 answer 37 views
37 views
Hi, when i try to execute this code i always get the error message from above, and i really want to know why, already tried to put a “public class XXXX” before the code, but not work anyway. public static String invertirPalabras(String cadena) { cadena += " "; String ... + palabra; if (cadena.charAt(i) == ' ') { nuevaCadena += palabra; palabra = ""; } } return nuevaCadena.trim(); }
asked Aug 2, 2020 Daniel Aguilar
3 votes
1 answer 1.9K views
1.9K views
Problem: Hello Kodlogs, I am a novice Java programmer. I just wrote my very first program a few minutes earlier. Now I want to write a program that can add two different integer numbers for me. I guess I done my coding well but it says something wrong with my writing and throws back an error: &ldquo ... []args){ int x = 10; int y = 15; int sum = x+y; System.out.println("Sum is: " + sum); } }
asked Mar 23, 2020 Gavin 15.3k points
0 votes
1 answer 121 views
121 views
Problem : I am trying to use the WCF4.0 template -REST. Also I am trying to make the method that uploads a file using the stream. The problem always occur at below line of code: Stream myserverStream = myrequest.GetRequestStream() ... connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
asked Dec 10, 2019 alecxe 7.5k points
0 votes
2 answers 4 views
4 views
Problem: I am stuck during learning as I have already mentioned in my question someone please cooperate me to continue my project-Thanks
asked Mar 27 ashik 10.7k points
0 votes
1 answer 50 views
50 views
I'm not sure how to proceed here as I'm not especially proficient in Oracle.
asked Jan 3 TeamScript 13.5k points
1 vote
1 answer 3 views
3 views
Problem: I am unable to find out the solution, Please solve it : password must contain at least 1 uppercase letter. try another one.
asked Apr 4 MUHAMMAD MUNEEB 80k points
1 vote
1 answer 2 views
2 views
Problem: Any ideas on what I need to do to fix this? java.sql.sqlexception: missing in or out parameter at index:: 1
asked 2 days ago MUHAMMAD MUNEEB 80k points
0 votes
1 answer 40 views
40 views
Why is this happening and how do I fix it?
asked Dec 28, 2020 TeamScript 13.5k points