question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid request format

See original GitHub issue

Issue

I have an issue with the pinning of file/directory. When I use Postman, everything works fine, but with SDK I always receive an error Invalid request format

Code example:

const readableStreamForFile = fs.createReadStream('./data/1.dat');
pinata.pinFileToIPFS(readableStreamForFile)
    .then((result) => {
        //handle results here
        console.log(result);
    }).catch((err) => {
        //handle error here
        console.log(err);
    });

Version

@pinata/sdk@1.1.10

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:43 (7 by maintainers)

github_iconTop GitHub Comments

107reactions
eightyfivecommented, Apr 9, 2021

Found it !

  async pinImage(dataURL) {
    const data = dataURL.replace(/^data:image\/png;base64,/, "");
    const buff = Buffer.from(data, "base64");
    const stream = Readable.from(buff);

    // ¡¡ THE HACK !!
    stream.path = "some_filename.png";

    const res = await pinata.pinFileToIPFS(stream);

    return res.IpfsHash;
  },

Basically the Pinata API complains if you don’t provide a filename for the file you want to pin. The hint was to look at the “Pin Manager” where file names are displayed for every upload.

@obo20 I believe the documentation / recipe book should point out this edge case or the API should return a better error message.

3reactions
isaadabbasicommented, Apr 22, 2021

@eightyfive Man, I can’t thank you enough ❤️ I approve his solutions works the best

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid Request Format Error - OutSystems 11 Documentation
You have an invalid value set in the 'Request Format' property of a REST API method, or you don't have any value set...
Read more >
403 - Invalid format - Rebrandly
403 - Invalid format · Request body is ill-formed e.g. invalid JSON · Required parameters are missing (either in body or in query...
Read more >
400 Bad Request - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server cannot or will not process the request ...
Read more >
c# - "Request format is invalid" - Stack Overflow
When trying to connect to the following web method, "Request format is invalid" is returned: public string myWebMethod(string test) { return ...
Read more >
Invalid requests and error responses - BMC Documentation
This section illustrates the XML format for an error request and response. The following figure shows a sample invalid request for the Find...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found