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

253
Vistas
Issue with POST request with API oauth2 / return: error 415

I have some issues with an API with oauth2 authentication. After I get the token, and I want to sent my POST request but it still gives me a 415 error (Unsupported Media Type). I'm sure my payload's fields are good because I tried with postman and it works, but I don't know if I have to JSON stringify the header (the payload I think, but I'm not sure at 100%). I run my code on Google apps script so I thought the problem came from apps script, but I can get the token and send GET request on it.

    function post_pers() {
     var url = "(my url)";
     var data = {
      "id": 32,
      "nom": "apij",
      "prenom": "joseph",
      "civiliteLongue": "Monsieur",
      "idTypePersonne": "PERSTPHYSIQUE  ",
      "ligne1Adresse": " ",
      "ligne2Adresse": " ",
      "ligne3Adresse": " ",
      "codePostal": " ",
      "commune": " ",
      "idPays": "FR",
      "iban": " ",
      "bic": " ",
      "titulaireCompte": " ",
      "domiciliationBanque": " ",
      "assujettiTva": true,
      "mediaPrefere": "Mail",
    }
    var payload = JSON.stringify(data);
    Logger.log("payload; "+payload)
    Logger.log("data; "+data)
     
     var header1 = {
    "accept": "application/json",
    "authorization": "Bearer (my access token)",
    "content-type": "application/json"
    }
    var header = JSON.stringify(header1);
    Logger.log("header; "+header)
    Logger.log("header1; "+header1)

    var options = {
        "method": "POST",
        "header": header,
        "payload": payload
    }
     var response = UrlFetchApp.fetch(url, options);
     Logger.log(response)
      }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

415 is unsupported media. This is usually due to Content-Type header typos. Your script is stringifying headers, which would make header unreadable by the server. Try

var options = {
    "method": "POST",
    "header": /*header*/header1,
    "payload": payload
}
about 4 years ago · Juan Pablo Isaza Denunciar
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