This the code I am currently using:
$.ajax({ dataType: "json", type: "Get", beforeSend: function(request) { request.withCredentials = true; request.setRequestHeader("Authorization", "Basic " + btoa($("#fs_api_key").val() + ":X")); request.setRequestHeader("Access-Control-Allow-Origin", "*"); request.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); }, url: "https://" + $("#fs_subdomain").val() + ".freshservice.com/api/v2/ticket_fields", success: function(data) { results = JSON.stringify(data.ticket_fields); groups = getProperty(results, "group", "choices"); $() var select = $(dropdown).empty(); $.each(groups, function(key, value) { select.append('<option value="'+ value +'">'+ key +'</option>'); }); }
Thanks!
Wade
Anyone know how to do an API get request from the iparams page? I keep getting this error when trying to pull in the groups to a dropdown for mapping between two systems.
Access to XMLHttpRequest at 'https://domain.freshservice.com/api/v2/ticket_fields' from origin 'https://d3h0owdjgzys62.cloudfront.net' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Yes, i have added this to my headers. It works from everywhere but the app.
Thanks