Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

531
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda