Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

532
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda