Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


APIs

Reply to topic
Bike Chat Forums Index -> The Geek Zone
View previous topic : View next topic  
Author Message

t121anf
World Chat Champion



Joined: 23 Feb 2007
Karma :

PostPosted: 17:22 - 26 Apr 2022    Post subject: APIs Reply with quote

At my work we are changing software, where I can currently write perl scripts to do stuff I now need to work with APIs.

I can use the likes of Postman to GET and PUT data but I need to be able to script this to work in batches, and work with files containing data to add via a PUT command after retrieving the record using GET, looping through the file.

Can anyone suggest an easy way to do this, general google'ing has directed me towards Python but I didn't know if it was possible to use Javascript or something else.

Thoughts? (other than get a new job Very Happy )
 Back to top
View user's profile Send private message You must be logged in to rate posts

Easy-X
Super Spammer



Joined: 08 Mar 2019
Karma :

PostPosted: 18:11 - 26 Apr 2022    Post subject: Reply with quote

If it has to be automated then Python's probably the best tool for the job but if the task is initiated manually don't forget Postman itself has pre- and post- action scripts (basically in Javascript.)

For example most Third-Party services I interface with have an authentication system and I extract out a token to use on later REST-API calls; all done within Postman.
____________________
Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter
 Back to top
View user's profile Send private message You must be logged in to rate posts

P.
Red Rocket



Joined: 14 Feb 2008
Karma :

PostPosted: 19:17 - 26 Apr 2022    Post subject: Reply with quote

Python is probably the best way to work with them.

I'm currently relearning stuff and using more automation tools, Python is alright for that, but Ansible is more what I need. Python is what most people use for generic API stuff like that.

Depends on your API though, I'm working with one right now which is just basic calls and pushes over HTTPS and I literally cba to script that Laughing
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

t121anf
World Chat Champion



Joined: 23 Feb 2007
Karma :

PostPosted: 14:43 - 27 Apr 2022    Post subject: Reply with quote

Thank you for your responses, didn't know Postman could script.

I suspect automation won't be required, it's possible but not at this time, I'll run them manually as required.

I found an example script on the suppliers website (eventually) which I've managed to re-use after a bit of fettling, it's a bash script that simply downloads everything about an entry to a file, which I can then add data to before re-uploading. For me this was easier than the Python examples where I had to extract each element.

I'll still explore Python but if bash scripting works it's a good starting point.
 Back to top
View user's profile Send private message You must be logged in to rate posts

Easy-X
Super Spammer



Joined: 08 Mar 2019
Karma :

PostPosted: 16:54 - 27 Apr 2022    Post subject: Reply with quote

Pre-request Script and [Post-request] Test...

This one's just a simple JSON object back and I store the authentication and refresh tokens as environment variables.
____________________
Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter
 Back to top
View user's profile Send private message You must be logged in to rate posts

P.
Red Rocket



Joined: 14 Feb 2008
Karma :

PostPosted: 13:12 - 28 Apr 2022    Post subject: Reply with quote

t121anf wrote:
Thank you for your responses, didn't know Postman could script.

I suspect automation won't be required, it's possible but not at this time, I'll run them manually as required.

I found an example script on the suppliers website (eventually) which I've managed to re-use after a bit of fettling, it's a bash script that simply downloads everything about an entry to a file, which I can then add data to before re-uploading. For me this was easier than the Python examples where I had to extract each element.

I'll still explore Python but if bash scripting works it's a good starting point.


Bash is winner, especially if you can do it all within there, easier life.

You can parse that clearly through Python, but it'll want it in a specific way.
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts
Old Thread Alert!

The last post was made 1 year, 353 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> The Geek Zone All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.06 Sec - Server Load: 0.5 - MySQL Queries: 17 - Page Size: 50.38 Kb