Failed to load Post API Method from JavaScript in out put parameter?
Question

Hi 

I m Trying to call The Post API Method via JavaScript in my screen in a Traditional Application But failed to load API. I m doing JSON Serialize in the API and in the screen Action I m Deserializing the output 

"$(document).ready(function(){
    var xyz = '"+Var1+"';
    $.ajax({
        url: 'https://...../test25/rest/RESTAPI2/RESTAPIMethod1',
        dataType: 'text',
        type: 'POST',
        //contentType: 'application/json',
        data: ({'Attribute1': xyz}), 
        success: function (data, status, xhr) {
            $('.js_test_inpt').val(data)
             $('.js_link').click();
            console.log(data);//output
        }        
      });   
});"
mvp_badge
MVP
Solution

Hi Chiranjit,

Could you try the below highlighted code changes in your implementation?

"
    $(document).ready(function() {
        var xyz = '" + Var1 + "';

        $.ajax({
            url: 'https://...../test25/rest/RESTAPI2/RESTAPIMethod1',
            dataType: 'json',
            type: 'POST',
            contentType: 'application/json',
            data: JSON.stringify({
                'Attribute1': xyz
            }),
            success: function(response) {
                $('.js_test_inpt').val(response.Attribute1);
                $('.js_link').click();
                console.log(response); //output
            }
        });
    });
"

I hope this helps you!


Kind regards,

Benjith Sam

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.