• Register
0 votes
51 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

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 13 views
13 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 Daniel Aguilar
3 votes
1 answer 833 views
833 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 Gavin 15.3k points
0 votes
1 answer 88 views
88 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 89 views
89 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