+ Start a Discussion
surya7628@gmail.com Ksurya7628@gmail.com K 

How To Update the record in Mongo DB with the using rest API

Hi All,

I need to update the record in mongo db,hear i have the mongo db record id in salesforce, based on that id i need to update the status from
(in process to completed) when ever user changed the status from 'in process' to 'completed' in salesforce.

Below code i have used for get method, Please suggest me how to upadate the record in mongo db with using of POST method.

public class AuthCallout {
    public void basicAuthCallout(){
        HttpRequest req = new HttpRequest();
        //req.setEndpoint('https://api.mongolab.com/api/1/databases/itsstest/collections/testorders/56bd8143c29ad480106dd219 apiKey=K6PuNd6v3s8PKcUk1nby7tQQ9viniTkW');
        req.setEndpoint('https://api.mongolab.com/api/1/databases/itsstest/collections/testorders/{!order.Mongo_DB_Order_ID__c} apiKey=K6PuNd6v3s8PKcUk1nby7tQQ9viniTkW');
        req.setMethod('GET');
        // Specify the required Mongo DB Order Id and status to access the endpoint
        // As well as the header and header information
        //String mongodborderid= '{!order.Mongo_DB_Order_ID__c}';
        //String status= '{!order.status}';
       // Blob headerValue = Blob.valueOf status);
        //String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        //req.setHeader('Authorization', authorizationHeader);
        // Create a new http object to send the request object
        // A response object is generated as a result of the request  
        Http http = new Http();
        HTTPResponse res = http.send(req);
        System.debug(res.getBody());
    }