Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Can we automate Java based Webservices
#1
Hi All,
I do not have idea on web-services API which is exposed .
here my question may be confusing , or I may not be able to explain.

Basically we have J2EE application that is one Monitoring tools, written in JAVA, that has REST API available, can we access those API using python and can we do the automation, or for doing automation activity we have to learn Java to access those REST API which is in Java. is there way I can find the difference?

Regards.
PythonBeginner
Quote
#2
Of course you can access the REST APIs in Python - those APIs are meant to be accessed by machines. You can use Requests to make the HTTP requests.
snippsat likes this post
Quote
#3
As mention bye @ndc85430 this is common task to do with Python.
Requests make it easy to do GET and POST request.
A example YouTube API,usually with big API you get a API key(free here) to use.
Example find how many subscriber a channel has,so insert key and channel id with f-string.
As a standard usually get JSON back,it's a dictionary when use it from Python.
import requests
 
api_key = 'xxxxxxxxxxxxxx'
channel_id = 'UC5kS0l76kC0xOzMPtOmSFGw' # chess.com
response = requests.get(f'https://www.googleapis.com/youtube/v3/channels?part=statistics&id={channel_id}&key={api_key}')
json_data = response.json()
print(json_data['items'][0]['statistics']['subscriberCount'])
Output:
285000
Quote
#4
(Mar-24-2020, 09:28 AM)snippsat Wrote: As a standard usually get JSON back,it's a dictionary when use it from Python.

Not necessarily though; some APIs serve XML. Thankfully Python includes an XML parsing library in ElementTree.
Quote
#5
Yes can also get XML,CSV or sometime a choice what format to get back,that why say i did say "usually".
(Mar-24-2020, 09:32 AM)ndc85430 Wrote: Thankfully Python includes an XML parsing library in ElementTree.
Yes,but i never use parser in standard library,use BeautifulSoup 4 or lxml.
Quote
#6
Thanks alot for you the input here
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Web scraping and java script yoz69100 2 251 Oct-14-2019, 07:41 PM
Last Post: yoz69100
  Can i use selenium to automate electron based desktop application UI dharmendraradadiya 0 474 Jul-22-2019, 01:20 PM
Last Post: dharmendraradadiya

Forum Jump:


Users browsing this thread: 1 Guest(s)