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

219
Views
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
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!