petersmithca/humhub-api

No JSON output?

Closed this issue · 6 comments

Hello. Maybe I'm missing something here, but I can't figure out how to output JSON with this api module. When I use the api it only outputs in XML.

Also a side question. Do you think you will be updating the notifications part to also show a list of unseen notifications per user_id? (right now it will show literally all unseen notifications, seems like unnecessary data)

If you use it in your browser, it will default to xml as browsers pass those headers to the api. To get json, you need to pass json headers, there is an addon in firefox that will allow you to do this for testing, but with curl or other code you need to ensure you specify "Content-Type: application/json"

As for the notifiications, that sounds like an easy addition, I will look at that when I can.

Ah I see. Is that normal? Because I think I've seen JSON output in my browser from other API's (not related to humhub), Maybe I'm wrong.

My knowledge about it is not that good xD It's just that my app developer prefers JSON API so I was trying to figure that one out. Thanks.

Anyways, great to hear you agree on the notifications idea!

Define normal? :P It's normal for Yii I believe, it had me stumped too at first. Most api's I've worked with in the past allow you to put an extension on your call (eg: /clients.json or /clients.xml) but I don't think yii does that. But it does come back as json if you use the headers correctly. The demo android app on my github page is getting the data in json format. - here was the extension I used to test as it allowed me to do PUT and PATCH http requests too. https://addons.mozilla.org/en-US/firefox/addon/poster/

I'd love to see or even screenshots of anything you develop, kinda felt for a while that the api wouldn't be used at all!

I am going to close this and add a new issue for the notifications by user so I don't forget. May be a bit before I can tackle, my old PC died and I need to rebuild my dev setup.