Re: Help with 400 Bad Request

Joe Martinez <[email protected]> Sat, 14 Feb 2015 21:20:03 -0800
Newsgroups gmane.comp.audio.musicbrainz.devel
Message-ID <CAD0McPpuHFko-LB5_Jrq=bskBJhO8zoN-iooY3RCA1wLtt-T2w@mail.gmail.com>
Ian,

Thanks for the response.  See my responses below...

On Sat, Feb 14, 2015 at 7:47 PM, Ian McEwen <[email protected]>
wrote:

> I'm looking now.
>
> The only thing that stands out to me is that ratings are numbers
> between 0 and 100. I'm assuming you meant four stars, which would be 80,
> not 4.
>

Yes, I was doing it based on a 0-5 rating.  I did that based on this page:

https://musicbrainz.org/doc/Rating_System

Do you know why it says 0-5, when it's really 0-100?  Or, is that page
talking about something altogether different?


> I'm not sure what exact process/tools you're using for submission since
> I'm unfamiliar with C#, but it works fine with me with, at the command
> line:
>
> curl --header "Content-Type: application/xml;charset=utf-8" -X POST
> --digest --user username:password -d @rate.xml
> http://musicbrainz.org/ws/2/rating?client=ianmcorvidae-0.0.1
>
> where username/password obviously get replaced and rate.xml contains:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#">
> <recording-list>
> <recording id="f5aec1b4-0162-489b-ad1a-2aeecebc7d8a">
> <user-rating>80</user-rating>
> </recording>
> </recording-list>
> </metadata>
>
>
Ok, so it sounds like the problem isn't with my XML at least.  Must be
something else in what I'm doing.


> Looking at the code, most normal errors should return an XML document
> with the error, e.g. if I change 'recording' to 'event' (since events
> can't be rated), I get:
>
> <?xml version="1.0" encoding="UTF-8"?><error><text>Entity type 'event'
> cannot have ratings. Supported types are: artist, recording, work,
> release-group, label</text><text>For usage, please see:
> http://musicbrainz.org/development/mmd</text></error>
>
> One thing I might check is how your C# tools handle response bodies for
> this sort of request -- perhaps it's throwing out the response that
> would tell you what's wrong?
>

Well, the interesting thing is that when I have other errors, I DO get
something back.

Here's an example:  If I leave out the User-Agent header, I get a Status
Code of  503 Service Unavailable, and the response body says:

<?xml version="1.0" encoding="UTF-8"?><error><text>Your requests are being
throttled by MusicBrainz because the application you are using has not
identified itself.  Please update your application, and see
http://musicbrainz.org/doc/XML_Web_Service/Rate_Limiting for more
information.</text><text>For usage, please see:
http://musicbrainz.org/development/mmd</text></error>

So, I'm definitely looking in the right place.  If I add the User-Agent
header back in, then again, I get a response status code of 400 Bad
Request, and an empty response body.

So, I'm not really sure what might be wrong, I guess :( hopefully something
> in
> there helps. One other small thing I notice is that you're giving a
> different client in the URL vs. the user-agent, which I'm guessing isn't
> intentional.
>

Actually, it is intentional.  From what I saw in the documentation, it
looks like User-Agent refers to the name/version of the client library, and
the client in the URL refers to the end user application.

On this page:
https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2#Submitting_data

it says:
"POST requests should always include a 'client' parameter in the URL (not
the body). The value of 'client' should be the ID of the client software
submitting data. This has to be the application's name and version number,
not that of a client library (client libraries should use HTTP's User-Agent
header). The recommended format is "application-version", where version
does not contain a - character."

Did I misinterpret that?


>
> Hope you find out what's wrong!
>

Me too!  I don't suppose there's a way I could send the response to a test
server that someone can look at and tell me what they see wrong on the
server side?

Thanks,
   Joe

_______________________________________________
MusicBrainz-devel mailing list
[email protected]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-devel