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\""
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
-
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. -
Works great ! Thanks for the weekend help 🙂
-
the json issue with multilevel objects has now been fixed so if you need that schema, you should be able to do so now.
-
Excellent! I will give it a try. Thanks
-
I finally got around to testing it. It works great! I am officially in the world of web3 with Xano. Thanks
-
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? -
sorry about that. Looks like some things changed with file upload regarding the new upgrade to PHP 8.1. This should be resolved now.
-
Thanks! I just retested and it works perfectly. Enjoy your weekend 🙂
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback