You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It'd be useful to be able to specify these per-request. I'm not sure how the best way to do that would be, as currently, you can pass in data to get, but it's treated as a query string.
A workaround for now is to make a new github instance with a custom apiVersion like:
Indeed - I actually recently added a way to specify per-request options:
gh.withOptions(apiVersion:'v3.raw').get"/foo"
But if we need to treat the response data as something other than JSON, we'd need a new option anyhow. I'm curious, do you have a specific use case in mind for this?
Check apiVersion against a regexp and if it matches certain things, treat the responses different. If we went with this version, we'd need to differentiate between apiVersion: 'v3.raw' and apiVersion: 'v3.raw+json', and I think that would end up a little weird since we're in the habit of automatically adding the +json for people.
Offer a new option, like raw: true or mediaType: 'raw', that would both modify the header and parse the response appropriately. I'm leaning towards this one because it makes it a little more obvious.
I think being able to specify the entire media type would be most flexible. Then, don't try to parse the response unless it has json in it. Thoughts?
On April 23, 2014 at 2:22:17 AM EDT, Ian Young notifications@github.com wrote:I can think of two ways to handle this: Check apiVersion against a regexp and if it matches certain things, treat the responses different. If we went with this version, we'd need to differentiate between apiVersion: 'v3.raw' and apiVersion: 'v3.raw+json' , and I think that would end up a little weird since we're in the habit of automatically adding the +json for people. Offer a new option, like raw: true or mediaType: 'raw' , that would both modify the header and parse the response appropriately. I'm leaning towards this one because it makes it a little more obvious. —Reply to this email directly or view it on GitHub.
Yeah, I was debating that too and came to the same tentative conclusion. We can have a mediaType option with default value of "+json". Then someone can set it to "raw" for raw files, or "raw+json" or whatever for weird cases. Githubot will combine it with the apiVersion and add a dot when necessary, and can just match against /\+json$/ and parse only those responses.
Activity
technicalpickles commentedon Apr 21, 2014
Actually, that workaround doesn't work because it tries to
JSON.parsethe result, and it's just plain text coming back.iangreenleaf commentedon Apr 22, 2014
Indeed - I actually recently added a way to specify per-request options:
But if we need to treat the response data as something other than JSON, we'd need a new option anyhow. I'm curious, do you have a specific use case in mind for this?
technicalpickles commentedon Apr 22, 2014
Yep, the Contents API https://developer.github.com/v3/repos/contents/ . At the very least, I think if the apiVersion matches
/raw/probably should not JSON.parse.iangreenleaf commentedon Apr 23, 2014
I can think of two ways to handle this:
apiVersionagainst a regexp and if it matches certain things, treat the responses different. If we went with this version, we'd need to differentiate betweenapiVersion: 'v3.raw'andapiVersion: 'v3.raw+json', and I think that would end up a little weird since we're in the habit of automatically adding the+jsonfor people.raw: trueormediaType: 'raw', that would both modify the header and parse the response appropriately. I'm leaning towards this one because it makes it a little more obvious.technicalpickles commentedon Apr 24, 2014
I think being able to specify the entire media type would be most flexible. Then, don't try to parse the response unless it has json in it. Thoughts?
On April 23, 2014 at 2:22:17 AM EDT, Ian Young notifications@github.com wrote:I can think of two ways to handle this: Check apiVersion against a regexp and if it matches certain things, treat the responses different. If we went with this version, we'd need to differentiate between apiVersion: 'v3.raw' and apiVersion: 'v3.raw+json' , and I think that would end up a little weird since we're in the habit of automatically adding the +json for people. Offer a new option, like raw: true or mediaType: 'raw' , that would both modify the header and parse the response appropriately. I'm leaning towards this one because it makes it a little more obvious. —Reply to this email directly or view it on GitHub.
iangreenleaf commentedon Apr 24, 2014
Yeah, I was debating that too and came to the same tentative conclusion. We can have a
mediaTypeoption with default value of"+json". Then someone can set it to"raw"for raw files, or"raw+json"or whatever for weird cases. Githubot will combine it with theapiVersionand add a dot when necessary, and can just match against/\+json$/and parse only those responses.