Need some help -> Pinata.cloud - API to upload (pin) a file

Options
I am trying to get a file upload to work for an API with pinata.cloud. The API enables you to upload an image to an IPFS node (messing around with some web3 APIs 😃). I am getting a 400 error with a message of "Invalid request format").

Any help would be greatly appreciated. I feel like I have just dumped a bunch of random info in this post 😎, but hopefully it gives someone enough info to recommend some new things for me to try.

As a note, I am able to get the Pinata authentication and usage APIs to work so I have the basics functioning.

Additionally, I am able to get the Pinata pinning API to work when I use Postman (just not with Xano, yet)

I have also referenced the Multipart Support info in this article as the basis for what I have been trying.
https://docs.xano.com/working-with-data/functions/external-api-request

This is the Pinata documentation for the pinning (file upload) API
https://docs.pinata.cloud/pinata-api/pinning/pin-file-or-directory

Here is the curl command from the PInata documentation:
curl --location --request POST 'https://api.pinata.cloud/pinning/pinFileToIPFS'
--header 'Authorization: Bearer PINATA JWT'
--form 'file=@/Users/Desktop/images/cat.JPG'
--form 'pinataOptions="{"cidVersion\"": 1}""'
--form 'pinataMetadata=""{\""name\"": \""MyFile\""

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
     few things here.
    1.  you don't want content-type: application/json - you can leave it blank and it will do the multipart content-type for you.
    2. looks like there is an issue with multi-dimensional arrays and multipart - your use case shows a bug which we can look into this coming week.
    3. if you want to fix this right now, remove the content-type and remove the keyvalues section and it should be good.
  • Steve Stava
    Steve Stava Member
    Options
    Works great ! Thanks for the weekend help 🙂
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
     the json issue with multilevel objects has now been fixed so if you need that schema, you should be able to do so now.
  • Steve Stava
    Steve Stava Member
    Options
     Excellent! I will give it a try. Thanks
  • Steve Stava
    Steve Stava Member
    Options
    I finally got around to testing it. It works great! I am officially in the world of web3 with Xano. Thanks
  • Steve Stava
    Options
     I am putting this comment here since it is the same context of calling the pinning API in Pinata.cloud. Things had been working fine until recently.

    The api call to the pinning service still works great but when I run it in Xano I get this error
    • Exception: Serialization of 'xano\api\CURLFile' is not allowed

    Even though that message is shown after the api call the image is still successfully pinned to Pinata.cloud. Any thoughts?
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
     sorry about that. Looks like some things changed with file upload regarding the new upgrade to PHP 8.1. This should be resolved now.
  • Steve Stava
    Options
    Thanks! I just retested and it works perfectly. Enjoy your weekend 🙂