HTTP Status code: 400 with client "EMSC"

Hey, after a few months I waned to use obspy again to get a bit of catalog data. Best client for my case would be “EMSC” but with using this I suddenly get the HTTP Status code: 400 and the message: “obspy.clients.fdsn.header.FDSNBadRequestException: Bad request. If you think your request was valid please contact the developers.”

Other clients do work with the same commands:

from obspy.clients.fdsn import Client
client = Client("EMSC")

starttime = UTCDateTime("2023-09-08T00:00:00")
endtime = UTCDateTime(starttime+86400)

coords = (-10.393066,29.707139,-6.668701,32.240683)
cat = client.get_events(starttime=starttime, endtime=endtime,
                        minmagnitude=-3, minlatitude=coords[1], maxlatitude=coords[3],
                        minlongitude=coords[0], maxlongitude=coords[2])


You can try initializing your client with Client(..., debug=True) then it will show any URLs that are fetched and as a last resort can copy/paste URLs into a browser. Doing that with your code shows the fetched URLS as:

And the server says it doesn’t like negative values in minimum magnitude. Just leave out minmagnitude=-3.0 (which frankly doesn’t do anything anyway :sweat_smile: ) and you’re good.

Two things though…

1 Like

It seems to be a bug in Event service rather than some specific setting on their server. They’re on 1.2.1, happens with us as well on version 1.2.4. However if I add maxmagnitude=-2 I get a regular 204 data error.

I could have sworn this topic has came up somewhere else but now I can’t find it… either I hallucinated that or it never got fixed!

1 Like

I sent an email and it’s already fixed on server side :astonished: :partying_face:

Thanks very much you two! A better error message would be useful for this case, I think.

I’m working on being better at getting all error message details passed through in the PR mentioned earlier, so error messages should be improved in next release