Non-json API requests

I noticed that when you submit non-JSON requests you get nasty error messages[1] when you hit the API. There are some bugs open about this and I was thinking of tackling it myself but I'm not sure what the solution is. Do we turn on wrap_parameters in v2 for other content types? Do we return a 400 status code when a person doesn't use JSON? Or is there another solution?

[1] https://bugzilla.redhat.com/attachment.cgi?id=916857

David

Actually, I can open a PR to fix the nil error in this particular case. Then the user just gets back a 400 error saying that name can't be blank. Would that suffice? Or should we still try to alert users that use unsupported content types?

David

··· ----- Original Message ----- > From: "David Davis" > To: "foreman-dev" > Sent: Friday, July 25, 2014 7:38:32 PM > Subject: [foreman-dev] Non-json API requests > > I noticed that when you submit non-JSON requests you get nasty error > messages[1] when you hit the API. There are some bugs open about this and I > was thinking of tackling it myself but I'm not sure what the solution is. Do > we turn on wrap_parameters in v2 for other content types? Do we return a 400 > status code when a person doesn't use JSON? Or is there another solution? > > [1] https://bugzilla.redhat.com/attachment.cgi?id=916857 > > David > > -- > You received this message because you are subscribed to the Google Groups > "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. >

Unsupported content type is way better. That error message would be very frustrating if if we're passing in a form-urlencoded with that value present.

··· > On Jul 26, 2014, at 9:41 AM, David Davis wrote: > > Actually, I can open a PR to fix the nil error in this particular case. Then the user just gets back a 400 error saying that name can't be blank. Would that suffice? Or should we still try to alert users that use unsupported content types? > > David > > ----- Original Message ----- > > From: "David Davis" > > To: "foreman-dev" > > Sent: Friday, July 25, 2014 7:38:32 PM > > Subject: [foreman-dev] Non-json API requests > > > > I noticed that when you submit non-JSON requests you get nasty error > > messages[1] when you hit the API. There are some bugs open about this and I > > was thinking of tackling it myself but I'm not sure what the solution is. Do > > we turn on wrap_parameters in v2 for other content types? Do we return a 400 > > status code when a person doesn't use JSON? Or is there another solution? > > > > [1] https://bugzilla.redhat.com/attachment.cgi?id=916857 > > > > David > > > > -- > > You received this message because you are subscribed to the Google Groups > > "foreman-dev" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to foreman-dev+unsubscribe@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > You received this message because you are subscribed to the Google Groups "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/d/optout.

+1 to returning "unsupported content type" since this will like save 'curl' users a lot of initial frustration.

··· ----- Original Message ----- > Unsupported content type is way better. That error message would be very > frustrating if if we're passing in a form-urlencoded with that value > present. > > > On Jul 26, 2014, at 9:41 AM, David Davis wrote: > > > > Actually, I can open a PR to fix the nil error in this particular case. > > Then the user just gets back a 400 error saying that name can't be blank. > > Would that suffice? Or should we still try to alert users that use > > unsupported content types? > > > > David > > > > ----- Original Message ----- > > > From: "David Davis" > > > To: "foreman-dev" > > > Sent: Friday, July 25, 2014 7:38:32 PM > > > Subject: [foreman-dev] Non-json API requests > > > > > > I noticed that when you submit non-JSON requests you get nasty error > > > messages[1] when you hit the API. There are some bugs open about this and > > > I > > > was thinking of tackling it myself but I'm not sure what the solution is. > > > Do > > > we turn on wrap_parameters in v2 for other content types? Do we return a > > > 400 > > > status code when a person doesn't use JSON? Or is there another solution? > > > > > > [1] https://bugzilla.redhat.com/attachment.cgi?id=916857 > > > > > > David > > > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "foreman-dev" group. > > > To unsubscribe from this group and stop receiving emails from it, send an > > > email to foreman-dev+unsubscribe@googlegroups.com. > > > For more options, visit https://groups.google.com/d/optout. > > > > > > > -- > > You received this message because you are subscribed to the Google Groups > > "foreman-dev" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to foreman-dev+unsubscribe@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. >

Now I understand that the non-json API issue is just a user not including -H "Content-Type:application/json" in the curl for -X POST/PUT calls. As such, let's only give an error message for API v2 as not to break anybody's scripts for API v1.

··· ----- Original Message ----- > From: "Tom McKay" > To: foreman-dev@googlegroups.com > Sent: Monday, July 28, 2014 5:51:52 PM > Subject: Re: [foreman-dev] Non-json API requests > > +1 to returning "unsupported content type" since this will like save 'curl' > users a lot of initial frustration. > > > ----- Original Message ----- > > Unsupported content type is way better. That error message would be very > > frustrating if if we're passing in a form-urlencoded with that value > > present. > > > > > On Jul 26, 2014, at 9:41 AM, David Davis wrote: > > > > > > Actually, I can open a PR to fix the nil error in this particular case. > > > Then the user just gets back a 400 error saying that name can't be blank. > > > Would that suffice? Or should we still try to alert users that use > > > unsupported content types? > > > > > > David > > > > > > ----- Original Message ----- > > > > From: "David Davis" > > > > To: "foreman-dev" > > > > Sent: Friday, July 25, 2014 7:38:32 PM > > > > Subject: [foreman-dev] Non-json API requests > > > > > > > > I noticed that when you submit non-JSON requests you get nasty error > > > > messages[1] when you hit the API. There are some bugs open about this > > > > and > > > > I > > > > was thinking of tackling it myself but I'm not sure what the solution > > > > is. > > > > Do > > > > we turn on wrap_parameters in v2 for other content types? Do we return > > > > a > > > > 400 > > > > status code when a person doesn't use JSON? Or is there another > > > > solution? > > > > > > > > [1] https://bugzilla.redhat.com/attachment.cgi?id=916857 > > > > > > > > David > > > > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups > > > > "foreman-dev" group. > > > > To unsubscribe from this group and stop receiving emails from it, send > > > > an > > > > email to foreman-dev+unsubscribe@googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > > > > > > > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "foreman-dev" group. > > > To unsubscribe from this group and stop receiving emails from it, send an > > > email to foreman-dev+unsubscribe@googlegroups.com. > > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "foreman-dev" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to foreman-dev+unsubscribe@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > You received this message because you are subscribed to the Google Groups > "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. >

Assuming that by "submit non-JSON requests” you meant the
"Content-type” header set to something other than "application/json",
then the response should a 415 “Unsupported Media Type”. If the issue
is with the “Accept” header set by the client to something other than
“application/json”, then the response should be a 406 “Not
Acceptable”. Please refer to [1] for the format of the body of the
response.

Cheers,
-d

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

··· On Mon, Jul 28, 2014 at 3:51 PM, Tom McKay wrote: > +1 to returning "unsupported content type" since this will like save 'curl' users a lot of initial frustration. > > > ----- Original Message ----- >> Unsupported content type is way better. That error message would be very >> frustrating if if we're passing in a form-urlencoded with that value >> present. >> >> > On Jul 26, 2014, at 9:41 AM, David Davis wrote: >> > >> > Actually, I can open a PR to fix the nil error in this particular case. >> > Then the user just gets back a 400 error saying that name can't be blank. >> > Would that suffice? Or should we still try to alert users that use >> > unsupported content types? >> > >> > David >> > >> > ----- Original Message ----- >> > > From: "David Davis" >> > > To: "foreman-dev" >> > > Sent: Friday, July 25, 2014 7:38:32 PM >> > > Subject: [foreman-dev] Non-json API requests >> > > >> > > I noticed that when you submit non-JSON requests you get nasty error >> > > messages[1] when you hit the API. There are some bugs open about this and >> > > I >> > > was thinking of tackling it myself but I'm not sure what the solution is. >> > > Do >> > > we turn on wrap_parameters in v2 for other content types? Do we return a >> > > 400 >> > > status code when a person doesn't use JSON? Or is there another solution? >> > > >> > > [1] https://bugzilla.redhat.com/attachment.cgi?id=916857 >> > > >> > > David >> > > >> > > -- >> > > You received this message because you are subscribed to the Google Groups >> > > "foreman-dev" group. >> > > To unsubscribe from this group and stop receiving emails from it, send an >> > > email to foreman-dev+unsubscribe@googlegroups.com. >> > > For more options, visit https://groups.google.com/d/optout. >> > > >> > >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "foreman-dev" group. >> > To unsubscribe from this group and stop receiving emails from it, send an >> > email to foreman-dev+unsubscribe@googlegroups.com. >> > For more options, visit https://groups.google.com/d/optout. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "foreman-dev" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to foreman-dev+unsubscribe@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/d/optout.

Right. I was thinking of throwing some 402s in as well to hopefully collect funds from API users.

David

··· ----- Original Message ----- > From: "Dmitri Dolguikh" > To: foreman-dev@googlegroups.com > Sent: Monday, July 28, 2014 11:18:28 AM > Subject: Re: [foreman-dev] Non-json API requests > > Assuming that by "submit non-JSON requests” you meant the > "Content-type” header set to something other than "application/json", > then the response should a 415 “Unsupported Media Type”. If the issue > is with the “Accept” header set by the client to something other than > “application/json”, then the response should be a 406 “Not > Acceptable”. Please refer to [1] for the format of the body of the > response. > > Cheers, > -d > > [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html > > On Mon, Jul 28, 2014 at 3:51 PM, Tom McKay wrote: > > +1 to returning "unsupported content type" since this will like save 'curl' > > users a lot of initial frustration. > > > > > > ----- Original Message ----- > >> Unsupported content type is way better. That error message would be very > >> frustrating if if we're passing in a form-urlencoded with that value > >> present. > >> > >> > On Jul 26, 2014, at 9:41 AM, David Davis wrote: > >> > > >> > Actually, I can open a PR to fix the nil error in this particular case. > >> > Then the user just gets back a 400 error saying that name can't be > >> > blank. > >> > Would that suffice? Or should we still try to alert users that use > >> > unsupported content types? > >> > > >> > David > >> > > >> > ----- Original Message ----- > >> > > From: "David Davis" > >> > > To: "foreman-dev" > >> > > Sent: Friday, July 25, 2014 7:38:32 PM > >> > > Subject: [foreman-dev] Non-json API requests > >> > > > >> > > I noticed that when you submit non-JSON requests you get nasty error > >> > > messages[1] when you hit the API. There are some bugs open about this > >> > > and > >> > > I > >> > > was thinking of tackling it myself but I'm not sure what the solution > >> > > is. > >> > > Do > >> > > we turn on wrap_parameters in v2 for other content types? Do we return > >> > > a > >> > > 400 > >> > > status code when a person doesn't use JSON? Or is there another > >> > > solution? > >> > > > >> > > [1] https://bugzilla.redhat.com/attachment.cgi?id=916857 > >> > > > >> > > David > >> > > > >> > > -- > >> > > You received this message because you are subscribed to the Google > >> > > Groups > >> > > "foreman-dev" group. > >> > > To unsubscribe from this group and stop receiving emails from it, send > >> > > an > >> > > email to foreman-dev+unsubscribe@googlegroups.com. > >> > > For more options, visit https://groups.google.com/d/optout. > >> > > > >> > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups > >> > "foreman-dev" group. > >> > To unsubscribe from this group and stop receiving emails from it, send > >> > an > >> > email to foreman-dev+unsubscribe@googlegroups.com. > >> > For more options, visit https://groups.google.com/d/optout. > >> > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "foreman-dev" group. > >> To unsubscribe from this group and stop receiving emails from it, send an > >> email to foreman-dev+unsubscribe@googlegroups.com. > >> For more options, visit https://groups.google.com/d/optout. > >> > > > > -- > > You received this message because you are subscribed to the Google Groups > > "foreman-dev" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to foreman-dev+unsubscribe@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. >

> Right. I was thinking of throwing some 402s in as well to hopefully collect funds from API users.

+1; In certain setups, If a rate of requests exceeds a predefined threshold.
-d

··· On Mon, Jul 28, 2014 at 5:01 PM, David Davis wrote:

David

----- Original Message -----

From: “Dmitri Dolguikh” witlessbird@gmail.com
To: foreman-dev@googlegroups.com
Sent: Monday, July 28, 2014 11:18:28 AM
Subject: Re: [foreman-dev] Non-json API requests

Assuming that by "submit non-JSON requests” you meant the
"Content-type” header set to something other than “application/json”,
then the response should a 415 “Unsupported Media Type”. If the issue
is with the “Accept” header set by the client to something other than
“application/json”, then the response should be a 406 “Not
Acceptable”. Please refer to [1] for the format of the body of the
response.

Cheers,
-d

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

On Mon, Jul 28, 2014 at 3:51 PM, Tom McKay thomasmckay@redhat.com wrote:

+1 to returning “unsupported content type” since this will like save 'curl’
users a lot of initial frustration.

----- Original Message -----

Unsupported content type is way better. That error message would be very
frustrating if if we’re passing in a form-urlencoded with that value
present.

On Jul 26, 2014, at 9:41 AM, David Davis daviddavis@redhat.com wrote:

Actually, I can open a PR to fix the nil error in this particular case.
Then the user just gets back a 400 error saying that name can’t be
blank.
Would that suffice? Or should we still try to alert users that use
unsupported content types?

David

----- Original Message -----

From: “David Davis” daviddavis@redhat.com
To: “foreman-dev” foreman-dev@googlegroups.com
Sent: Friday, July 25, 2014 7:38:32 PM
Subject: [foreman-dev] Non-json API requests

I noticed that when you submit non-JSON requests you get nasty error
messages[1] when you hit the API. There are some bugs open about this
and
I
was thinking of tackling it myself but I’m not sure what the solution
is.
Do
we turn on wrap_parameters in v2 for other content types? Do we return
a
400
status code when a person doesn’t use JSON? Or is there another
solution?

[1] https://bugzilla.redhat.com/attachment.cgi?id=916857

David


You received this message because you are subscribed to the Google
Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google
Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups “foreman-dev” group.
To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.