Problem getting service records

Hi !

I’ve just started making some tests with the API through PHP. Everything is working well except for service records part.
It keeps sending me error 404 - Resource not found.
I don’t know what I’m doing wrong as I copied the request URL from the demo.

Here’s my request URL:

> https://www.haloapi.com/stats/h5/servicerecords/campaign?players=BananasSplitter

and here’s what it returns :

> HTTP_Request2_Response Object ( [version:protected] => 1.1 [code:protected] => 404 [reasonPhrase:protected] => Resource Not Found [effectiveUrl:protected] => https://www.haloapi.com/stats/h5/servicerecords/campaign [headers:protected] => Array ( [content-length] => 54 [content-type] => application/json [date] => Wed, 04 Nov 2015 11:07:57 GMT ) [cookies:protected] => Array ( ) [lastHeader:protected] => date [body:protected] => { “statusCode”: 404, “message”: “Resource not found” } [bodyEncoded:protected] => 1 )

The code I’m using is the same that is given in the doc and as I said it works for any other part of the API.
Do I have to set permission somewhere on my profil ?

Thanks for your help guys

That request URL works fine for me. First thing that comes to mind is that you may be using the wrong HTTP method, like POST instead of GET.

Feel free to post some code (maybe use a GitHub Gist, or pastebin).

Happy to take a look.

Thanks for your answers!

Here’s a gist for you:
https://gist.github.com/GRosay/4d8f3712c6b710ae88c1

As I said, the script works for others API part but not for service records and I can’t figure what is the problem.

Not too familiar with HTTP_Request2 but does it work without the “$request->setBody(”{body}");" line? Doesn’t seem necessary or even valid for this request.

> 2533274792173269;5:
> Not too familiar with HTTP_Request2 but does it work without the “$request->setBody(”{body}");" line? Doesn’t seem necessary or even valid for this request.

Mh it’s still not working without the line.

I’m not familiar either but I left it as it was in the exemple from the documentation (but you’re right, I don’t think it’s necessary in that case).

> 2533274792173269;5:
> Not too familiar with HTTP_Request2 but does it work without the “$request->setBody(”{body}");" line? Doesn’t seem necessary or even valid for this request.

HTTP/1.1 spec says that the body of a GET request is basically ignored. But yes, delete that line.

> 2533274808660054;6:
> > 2533274792173269;5:
> > Not too familiar with HTTP_Request2 but does it work without the “$request->setBody(”{body}");" line? Doesn’t seem necessary or even valid for this request.
>
>
> Mh it’s still not working without the line.
>
> I’m not familiar either but I left it as it was in the exemple from the documentation (but you’re right, I don’t think it’s necessary in that case).

Try this: https://gist.github.com/DerFlatulator/d8316113c2afe41ef91e

  • removed body
  • moved query params from the url to the $parameters arrayDisclaimer: I’ve never used that library and haven’t written PHP in a while.

Well, thanks you Der Flatulator ! It works like a charm now.
While copying the example I didn’t take the time to understand it… Ok, now I’m ashamed.

Thanks everyone for your help!