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

218
Vistas
Trying to post image to Instagram from a Javascript using Instagram API

I am doing this in Google App Scripts. Seems pretty straightforward, so I first setup Meta Developer info, and created a Instagram Test User and created a valid long-lived token for that account to use.

var userID = "139**********890";
// a fresh Instagram API Long Live Access Token
var accessToken = "IGQVJWRzBzWGp2d1hIUThZ*****************************************************************************************************************cWVFclczbDBmTEx0U1B2RAZDZD";

function insertPost3() {
    var formData = {
    'image_url': "https://drive.google.com/uc?id=10QubQQV218reR2qSQ-9qA0QmrOoYoCIL&export=download",
    'caption': "here is sample text",
    'access_token': accessToken
  };
  var options = {
    'method' : 'post',
    'payload' : formData,
    'muteHttpExceptions' : true
  };
  const container = 'https://graph.facebook.com/' + userID + '/media';

  Logger.log(container);

  const response = UrlFetchApp.fetch(container, options);

  const creation = response.getContentText();
  var data = JSON.parse(creation);
  var creationId = data.id
  var formDataPublish = {
      'creation_id': creationId,
      'access_token': accessToken
  };
  var optionsPublish = {
    'method' : 'post',
    'payload' : formDataPublish
  };
  const sendinstagram = 'https://graph.facebook.com/' + userID + '/media_publish';
  
  UrlFetchApp.fetch(sendinstagram, optionsPublish);
}

And just getting a generic error back, even with muteHttpExceptions. Not sure how to proceed.

Exception: Request failed for https://graph.facebook.com returned code 400. Truncated server response: {"error":{"message":"Invalid OAuth access token.","type":"OAuthException","code":190,"fbtrace_id":"AhuSzful3sLsd7qKziJH6Oi"}} (use muteHttpExceptions option to examine full response)

Any ideas, sample code, or resources to read would be great.

This is one of the guides I've been using to do this: https://developers.facebook.com/docs/instagram-api/guides/content-publishing/

Thanks for any help!!

phi

about 4 years ago · Juan Pablo Isaza
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