• Register
0 votes
55 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 15 views
15 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 5.1k points
0 votes
1 answer 20 views
20 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.3K views
1.3K 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 100 views
100 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
1 answer 8 views
8 views
I'm not sure how to proceed here as I'm not especially proficient in Oracle.
asked Jan 3 TeamScript 9.2k points
0 votes
1 answer 14 views
14 views
Why is this happening and how do I fix it?
asked Dec 28, 2020 TeamScript 9.2k points
0 votes
1 answer 461 views
461 views
Problem : Below error is very strange and I don't know how to reproduce it and how to fix the error. As I made the lot of searches but nothing was useful for me. “Java.lang.securityexception: permission denied (missing internet permission?)”.
asked Jan 21, 2020 jwilliam 3.9k points
0 votes
1 answer 235 views
235 views
Problem : I am getting below error while executing Android Code java.lang.securityexception: permission denied (missing internet permission?)
asked Oct 22, 2019 peterlaw 6.9k points
0 votes
2 answers 117 views
117 views
Problem : I am new to the SQL. What am I doing wrong here? SELECT LEFT(SUBSTRING(batchinfo.datapath, PATINDEX('%[0-9][0-9][0-9]%', batchinfo.datapath), 8000), PATINDEX('%[^0-9]%', SUBSTRING(batchinfo.datapath, PATINDEX('%[0-9][0-9][0-9]%',batchinfo. ... I am trying to do group by the first, second, and third columns having the max rid. It is works perfectly fine without the group by and having.
asked Nov 27, 2019 alecxe 7.5k points