proofgeist / generator

Generator - Store, explore, share and create FileMaker Code
MIT License
35 stars 8 forks source link

FogBugz JSON API not handled on return #8

Open rwu2359 opened 7 years ago

rwu2359 commented 7 years ago

result of getting a token as per image

screen shot 2016-11-06 at 12 39 04

using { "name": "Fogbugz token", "notes": "", "request": { "method": "POST", "url": "https://rwu.fogbugz.com/f/api/0/jsonapi", "query": {}, "headers": { "Content-Type": "application/json" }, "data": { "cmd": "logon", "email": "myemail", "password": "mypassword" } } }

using API kitchen the results returned are {"data":{"token":"k4i43mp1jljkmrajnjkkl1e76a3hsb"},"errors":[],"warnings":[],"meta":{"jsdbInvalidator":"XgTKsKzswka68vt6hyndjA2","clientVersionAllowed":{"min":4,"max":4}},"errorCode":null,"maxCacheAge":null}

and headers Access-Control-Allow-Origin: * Content-Type: text/javascript; charset=utf-8 Connection: close Strict-Transport-Security: max-age=15552000 Date: Sun, 06 Nov 2016 12:27:39 GMT X-Frame-Options: SAMEORIGIN Content-Encoding: gzip Content-Length: 185 Cache-Control: private, max-age=0 Vary: Accept-Encoding

This issue can be fixed by changing line #130 in the HTTP script in Generator to IF ( $contentType = "application/json" or $contentType = "text/javascript" )

Why is this section (#125--136) in the Generator script not in the script that gets copied to user files??

toddgeist commented 7 years ago

I'll have to take a look. I can't remember

toddgeist commented 7 years ago

@rwu2359 will you check the latest version. See if this has been resolved for you

rwu2359 commented 7 years ago

Latest version breaks the request. Because dataQuoted is not set as a parameter it is turning the data part of the post to ?, which the API is rightly reading as not valid JSON...

on line #59

not IsEmpty ( $Data ) & $dataQuoted

fails as $dataQuoted = "dataQuoted" does not exist, as it is the error from the JsonGet CF. Better test - not isempty (..) and PatternCount ( $dataQuoted ; "not exist" ) > 0 ???

toddgeist commented 7 years ago

Ok, so I see how that could be.

toddgeist commented 7 years ago

OK can you try it now. Latest version 1.0.5 See if that fixes it.

Thanks

rwu2359 commented 7 years ago

Fogbugz has been down for a bit. This issues is now fixed with the latest version, except it brings up another issue which I will raise separately about handling returned body which contains just some html, no identifiable JSON