Chilkat Online Tools

Node.js / Salesforce Platform APIs / Create and Save Quote Proposal API

Back to Collection Items

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}


function chilkatExample() {

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    var http = new chilkat.Http();
    var success;

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "saver": "SBQQ.QuoteDocumentAPI.Save",
    //   "model": {
    //     "name": "test",
    //     "quoteId": "<SFDC_ID>",
    //     "templateId": "<SFDC_ID>",
    //     "outputFormat": "PDF",
    //     "language": "en_US",
    //     "paperSize": "Default"
    //   }
    // }

    var json = new chilkat.JsonObject();
    json.UpdateString("saver","SBQQ.QuoteDocumentAPI.Save");
    json.UpdateString("model.name","test");
    json.UpdateString("model.quoteId","<SFDC_ID>");
    json.UpdateString("model.templateId","<SFDC_ID>");
    json.UpdateString("model.outputFormat","PDF");
    json.UpdateString("model.language","en_US");
    json.UpdateString("model.paperSize","Default");

    // Adds the "Authorization: Bearer <access_token>" header.
    http.AuthToken = "<access_token>";
    http.SetRequestHeader("Content-Type","application/json");

    // resp: HttpResponse
    var resp = http.PostJson3("https://domain.com/services/apexrest/SBQQ/ServiceRouter?loader=QuoteDocumentAPI.SaveProposal","application/json",json);
    if (http.LastMethodSuccess == false) {
        console.log(http.LastErrorText);
        return;
    }

    console.log(resp.StatusCode);
    console.log(resp.BodyStr);


}

chilkatExample();

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-d '{
    "saver": "SBQQ.QuoteDocumentAPI.Save",
    "model": {
        "name": "test",
        "quoteId": "<SFDC_ID>",
        "templateId": "<SFDC_ID>",
        "outputFormat": "PDF",
        "language": "en_US",
        "paperSize": "Default"
    }
}'
https://domain.com/services/apexrest/SBQQ/ServiceRouter?loader=QuoteDocumentAPI.SaveProposal

Postman Collection Item JSON

{
  "name": "Create and Save Quote Proposal API",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "type": "text",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"saver\": \"SBQQ.QuoteDocumentAPI.Save\",\n    \"model\": {\n        \"name\": \"test\",\n        \"quoteId\": \"<SFDC_ID>\",\n        \"templateId\": \"<SFDC_ID>\",\n        \"outputFormat\": \"PDF\",\n        \"language\": \"en_US\",\n        \"paperSize\": \"Default\"\n    }\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{_endpoint}}/services/apexrest/SBQQ/ServiceRouter?loader=QuoteDocumentAPI.SaveProposal",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "services",
        "apexrest",
        "SBQQ",
        "ServiceRouter"
      ],
      "query": [
        {
          "key": "loader",
          "value": "QuoteDocumentAPI.SaveProposal"
        }
      ]
    },
    "description": "The Read Product API takes the request’s product ID, pricebook ID, and currency code and returns a Product model. The Product model loads the product from your catalog when the user requests it.\nAvailable in: Salesforce CPQ Summer ’16 and later\nSpecial Access Rules: Users must have read access to the product2 object.\n\nhttps://developer.salesforce.com/docs/atlas.en-us.cpq_dev_api.meta/cpq_dev_api/cpq_api_read_product.htm"
  },
  "response": [
  ]
}