on-internet
← Community

How to call a REST based API from Databricks using pyspark?

Stack Overflow ·

I want to call a REST based microservice URL using GET/POST method and display the API response in Databricks using pyspark. Currently I am able to achieve both using python. Here is my python script for POST method: import requests as req import json input_data = {'A': 1, 'B': 2} url = 'http://myurl/v1/post' input_headers={ "Content-Type": "application/json", "header1":"value1", "header2":"value2, "header3":"value3" } resp = req.post (url,headers=input_headers, data=json.dumps(input_data)) print(resp.text) And my script for GET method: import requests as req url = 'http://myurl/v1/get' resp=

Comments

Sign in or sign up to comment and upvote.

No comments yet.