getImage() returns "Error: Bad response status code 301"

Hi,
I am trying to run the github example for getImage() function and i am getting the error “Bad response status code 301”.

github-example:

var plotly = require('plotly')('username','apiKey');
var fs = require('fs');

var trace1 = {
  x: [1, 2, 3, 4],
  y: [10, 15, 13, 17],
  type: "scatter"
};

var figure = { 'data': [trace1] };

var imgOpts = {
    format: 'png',
    width: 1000,
    height: 500
};

plotly.getImage(figure, imgOpts, function (error, imageStream) {
    if (error) return console.log (error);

    var fileStream = fs.createWriteStream('1.png');
    imageStream.pipe(fileStream);
});

The same code was working fine two days ago, so i believe that the issue is related to the new url change.

Thanks for your help,
Thomas

2 Likes

Same here, I have a service using that function and has been working for almost a year without problems, but suddenly start to fail.

1 Like

started having the same issue around the same time as you. still not working today. it’s been working for a couple years straight with no problems.

related, had a similar issue a couple years ago

still getting this error. anyone figure it out?

I’ve started to see the exact same issue here as of a couple of weeks. Would really appreciate some support. My app had been running for 1 year without any issues. Anyone understand the issue!?

ChartsToImage error getting image:Error: Bad response status code 301
ChartsToImage error getting image:Error: Bad response status code 301
ChartsToImage error getting image:Error: read ECONNRESET
ChartsToImage error getting image:Error: Bad response status code 301
ChartsToImage error getting image:Error: Bad response status code 301
ChartsToImage error getting image:Error: Bad response status code 301
ChartsToImage error getting image:Error: Bad response status code 301

Regards,

Alejandro

1 Like

Has anyone got a solution for this?

Ok, here’s the fix according to https://github.com/plotly/plotly-nodejs/issues/62

var plotly = require('plotly')({"username" :"yourUserName", "apiKey" : "yourApiKey", "host" : "chart-studio.plotly.com"})

Apparently this is caused by the new change of domain.

1 Like

I’ve tried this new fix and it isn’t working. Code was working just fine two days ago, and today I ran the same functions and I’m getting a similar error from a similar issue:

Error: Bad response status code 500 at the same client handler index.js line 237:25

Any ideas?

Tips to fix-
Make sure the HTTP version of your site redirects to HTTPS. Every website should use HTTPS.
Remove pages with 301 status codes from your sitemap.
Fix redirect chains.
Fix redirect loops.
Fix broken redirects.
Redirect 404 pages

Regards,
Rachel Gomez