Activity Forums Salesforce® Discussions How to use standard Salesforce REST API from Visualforce page ?

  • Laveena

    Member
    August 23, 2019 at 5:17 am

    Hi Prachi,

    $.ajax({

    type: reqType,

    beforeSend: function (xhr)

    {

    xhr.setRequestHeader("Authorization", 'Bearer {!$API.Session_ID}');

    },

    headers : {'Content-Type' : 'application/json; charset=utf-8'},

    url: postUrl,

    data: postData,

    dataType: 'text'

    })

    .done(function( data ) {

    //Code if success

    })

    .fail(function(xhr,textstatus,error){

    //Code if fail

    });

    Thanks

  • Hariom Chaudhary

    Member
    August 23, 2019 at 5:18 am

    Hi,

    Salesforce has introduced a concept called AJAX ToolKit, which help us to make REST API call from the JavaScript in Visualforce Page.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos