Hi All,
I upgraded today to use the API plugin, so we can create a ticket in our Freshdesk ticketing platform. Looks to be a straight forward setup but I am receving an error in the log saying that the content type is wrong even though I have selected JSON.
Does anyone here have any ideas on why this would be the case? Formidbale Support are blaming the third party but I do not think that is the case as I can create a ticket via Curl as long as I set the right content type. Setup screenshot attached.
Error Message: \"code\": \"invalid_content_type\", \"message\": \"Content-Type header is set to application/x-www-form-urlencoded. It should be set to application/json\"}\", \"response\":
Details
WP Version: 6.0.1
Formidable Version: 5.4.4
Formidable API 1.11
Regards
Matt
Thanks Victor.
The error I posted is from the logs and the API works via curl from the CLI. Just need a way to force formidable to send the right content type.
Matt
Send it as raw JSON.
Hi,
All sorted. The issue is only related to the test connection button. That ignores the field settings.
The ajax function lnked to the button is very basic. I added a content type and data type to the ajax and changed the returnerror.
function frmapi_test_connection(){ var settings = jQuery(this).closest('.frm_single_api_settings'); var key = settings.data('actionkey'); var baseName = 'frm_api_action['+key+'][post_content]'; var url = jQuery('input[name="'+baseName+'[url]"]').val(); var key = jQuery('input[name="'+baseName+'[api_key]"]').val(); var testResponse = settings.find('.frmapi_test_resp'), button = this; if (url == '') { settings.find('.frmapi_test_connection').html('Please enter a URL'); return; } else if ( url.indexOf('[') != '-1' ) { testResponse.html('Sorry, Dynamic URLs cannot be tested'); return; } button.classList.add( 'frm_loading_button' ); testResponse.html(''); jQuery.ajax({ type:'POST',url:ajaxurl, contentType: "application/json", dataType: "json", data:{action:'frmapi_test_connection',url:url,key:key}, success:function(html){ testResponse.html(html); button.classList.remove( 'frm_loading_button' ); } }); }Regards
Matt
Please login or Register to submit your answer