LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-19-2019, 11:00 AM   #1
PoleStar
Member
 
Registered: Jul 2010
Posts: 231

Rep: Reputation: 2
curl/python-library suggestion.


Hi,

I will be doing
Code:
curl -X GET --header 'Accept: application/json' --header  'https://dev.my-company.com/api/data'
and I will be also doing 'POST' calsl to the api.
In 'POST' calls input data structures could get pretty large. So I think it will be harder to do it with shell script.

I am thinking of using python. Is it a good idea ? what libraries should I use ?

Thank you
 
Old 12-19-2019, 12:13 PM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,923

Rep: Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319
python obviously can be used (or probably better to say python3), you need to look for examples on the net. Also you can try perl or other languages.
Using python you can try the request module, pycurl or urllib2 or probably others. See for example: https://stackoverflow.com/questions/...tive-in-python
https://www.edureka.co/community/251...a-curl-command
 
1 members found this post helpful.
Old 12-19-2019, 05:35 PM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by PoleStar View Post
In 'POST' calls input data structures could get pretty large. So I think it will be harder to do it with shell script.
Put the data structures in a file, say /home/myself/postdata, and submit them like this:
Code:
curl -X POST -d @/home/myself/postdata 'https://dev.my-company.com/api/data'
You can use any programming language to generate the content of /home/myself/postdata. If you have never used Python, there will be a certain learning curve. Although Python has the reputation of being beginner-friendly, I would first explore how my task can be accomplished with the tools that I know.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Curl-OPENSSL1 update for SUSE 11 SP4 - Backdates Curl DaveUSC SUSE / openSUSE 5 05-31-2019 02:04 PM
[SOLVED] Slackware ARM 14.2 - Updates Rollback - curl-7.57.0 - curl-7.58.0 abga Slackware - ARM 13 02-02-2018 11:44 AM
CentOS 6.7 has really OLD curl. Best way to update curl? sneakyimp Linux - Server 4 04-26-2016 03:06 PM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
cURL: Server has many IPs, how would I make a cURL script use those IPs to send data? guest Programming 0 04-11-2009 11:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration