how to create a gist in github that returns json data

The problem is the HTTP response type is text/plain but you will need application/json for most clients to handle it properly.

Update: using rawgit.com I was able to get your test working with the correct content-type.

My test Gist: https://gist.githubusercontent.com/anonymous/85dbc2c71023f24c2e26/raw/849848a71a1805a314897f9fe98eb7dc43e2e9b9/gistfile1.json

My RawGit URL: https://rawgit.com/anonymous/85dbc2c71023f24c2e26/raw/849848a71a1805a314897f9fe98eb7dc43e2e9b9/gistfile1.json

Using HTTP GET, sending over:

GET https://rawgit.com/anonymous/85dbc2c71023f24c2e26/raw/849848a71a1805a314897f9fe98eb7dc43e2e9b9/gistfile1.json HTTP/1.1
Accept: application/json
Host: rawgit.com

Receiving back:

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 24 Dec 2014 10:57:07 GMT
Content-Type: application/json
Connection: keep-alive
X-Content-Type-Options: nosniff
X-Robots-Tag: none
RawGit-Naughtiness: 0
Access-Control-Allow-Origin: *
ETag: "0250189db62d31523a5cd0da47449eb4"
Cache-Control: max-age=300
Vary: Accept-Encoding
RawGit-Cache-Status: HIT
Content-Length: 104

[{ Name: "Vignesh", Salary: 30000 },{ Name: "Yuvraj", Salary: 90000 },{ Name: "Nithya", Salary: 87000 }]

And a couple screenshots:

enter image description here

enter image description here


  1. Put your json in a new gist.
  2. Look for the option raw. Click it and you have plain text version of whatever you had.

One thing to note is that it appears json data, but the headers reveal - Content-Type:text/plain

You can use https://rawgit.com/ for modifying the headers.

Tags:

Git

Github

Gist