Re: Help with 400 Bad Request

Ian McEwen <[email protected]> Sat, 14 Feb 2015 20:47:18 -0700
Newsgroups gmane.comp.audio.musicbrainz.devel
Message-ID <[email protected]>
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.

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>

However, this also works fine with 4 rather than 80, though the result
on the site is that it appears to be unrated, since that's less than 1
star.

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?

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.

Hope you find out what's wrong!

On Sat, Feb 14, 2015 at 05:44:40PM -0800, Joe Martinez wrote:
> I'm attempting to write a client library to send ratings to MusicBrainz.
> There is no existing client library for my environment (c#) that supports
> sending ratings, so I am attempting to write my own.
>
> Here's the info about my http request:
>
> URL = http://musicbrainz.org/ws/2/rating?client=MyGrooves-0.0.1
>
> Method: POST
>
> Request Headers:
> UserAgent = JmmRater/1.0.0 ( [email protected] )
>
> Content Headers:
> Content-Type = application/xml; charset=utf-8
>
> Content:
> <?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>4</user-rating>

>                         </recording>
>                     </recording-list>
>                 </metadata>
>
> I am sending Digest authentication credentials.
>
> When I send this, I am getting a status code of 400 Bad Request.
> The content of the response is blank.
>
> I'm not sure where to go from here.  Does anyone see anything above that
> points to what I'm doing wrong?  If not, how can I debug this?
>
> Thanks,
>    Joe

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

_______________________________________________
MusicBrainz-devel mailing list
[email protected]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-devel
signature.asc (application/pgp-signature, 181 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlTgFsMACgkQq+0avXExp29fLACgiApAC/FCOm1i7Fk0dNVBpiBP
BUYAn3IS4n/1cyMf59x8SrmjLtXGwueE
=452d
-----END PGP SIGNATURE-----