Expand my Community achievements bar.

Come join us for our Coffee Break this WEDNESDAY on top takeaways from Adobe Summit!

API and JSONP

Avatar

Level 1
We have 3 different instances of WF running for 3 different departments. I am using the API to gather info from 2 other instances for reporting purposes. I have read access to projects on these. I can run the query from my browser window and get a JSONresponse. I also have it working in Fiddler. However, when I make an AJAX request from JavaScript with datatype set to JSON, I get a 401 Unauthorized error. Also No 'Access-Control-Allow-Origin' header is present on the requested resource. I understand that being on different servers causes cross-domain issues. So, I set the datatype to JSONP. This actually works. But I get a parse error because where I am asking for JSONP, the server is giving me JSON. Is there a way around this? Can I ask for and receive JSONP. or can I intercept the JSON before the parse error and reformat? Marshall Johnson LDS Church-Finance
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

5 Replies

Avatar

Level 4
Can you show us your javascript code and the errors you are getting. Workfront does not support JSONP, but they allegedly has an option that will enable CORS (Cross-Origin) in Setup -> System -> Preferences -> "Allow Embedding of Workfront in an iframe". From there you will need to also enable CORS on the server you are using to execute your API Code. It's probably best to just perform all API http requests from the server-side as is secure and standard and pass it back to the UI as json. Infrastructure wise, this would mean you may have an AJAX request from the UI of your website, this reaches out to your server and asks for Workfront data, your server sends API requests to Workfront and receives http responses, your server sends that response back to your client's UI, your client's UI parses the response text as JSON. James Bender Jackson/JTS

Avatar

Level 5
@Marshall, I've heard that WF is deprecating support for JSONP. They're replacing it with white-listed domains. No special code required. Contact WF support and ask them to add the domain name from which your hosting the embedded page to an internal whitelist. For example, if the embedded page is located at https://apps.lds.org/internal/test.htmll then you should have them add htts://apps.lds.org. Include all possible hosting domains in your request since setting this up internally is a bit resource intensive. Scott Brady CapabilitySource

Avatar

Level 10
Scott is correct, Workfront will deprecate JSONP soon, you can find more details in "https://support.workfront.com/hc/en-us/articles/360006949754-Ending-Support-for-JSONP" this article . Anna ANNA GRIGORYAN Group Product Manager Workfront

Avatar

Level 10
Hi Anna, Would you please double-check and correct your This Article link (which seems to be self referencing to this post)? Thanks, Doug Doug Den Hoed - AtAppStore Got Skills? Lend a hand! https://community.workfront.com/participate/unanswered-threads

Avatar

Level 10
Thanks for catching that Doug. I have fixed the URL to point to the documentation now. ANNA GRIGORYAN Group Product Manager Workfront