Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

534
Views
Sending PUT request to KV Core API in Google Apps Script

I'm trying to set up GAS to send an API call to my CRM. Here is the link for the API documentation.

I'm attempting to use the code for sending a text via the API. Below is what they provided. I have changed this code to work with GAS(see further down):

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer {{api_token}}");

var raw = JSON.stringify({
  "message": ""
});

var requestOptions = {
  method: 'PUT',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.kvcore.com/v2/public/contact/{{contact_id}}/text", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

I adapted the code provided to work with GAS. This is what I'm actually trying to run:

function kvCoreStyle(){
  var myHeaders = {
   "Content-Type":"application/json",
   "Authorization":"Bearer {{TOKENID}}"
}

  var raw = {
      "message":"let me know if you get this text"
   }

  var requestOptions = {
   "method":"PUT",
   "headers":myHeaders,
   "body": raw,
   "redirect":"follow"
};
 
  UrlFetchApp.fetch("https://api.kvcore.com/v2/public/contact/{{ContactID}}/text", requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log('error', error));
}

Unfortunately, I keep getting an error saying "Request body must be a valid JSON string"

I have tried using JSON.stringify() on multiple portions of this and can not get it to work at all. Any advice would be appreciated!

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!