databricks POST call to execute a notebook with parameters - databricks

In my notebook I have declared parameters and through the Jobs UI I am able to successfully execute the notebook by passing the default and different parameters. Now I am trying to run the notebook through a POST call. I wanted to know how to pass the notebook parameters?
On Postman this is what I tried but none of them worked,
https://

I was able to figure out. I passed the parameters in the body when testing through Postman and as JSON payload when using Python requests.

Related

(Asana) XML is invalid: Headers are not supported on this surface

I am pretty sure I am using exactly the same code in the following two cases, as I tested it on Postman first.
The first time I tried to create a task from Postman, it has no issue.
The next time I tried to do the same from my NodeJS server, and it shows this error. I tried the client SDK package and manually calling through Axios, both are not working and throwing the same error.
Is the Asana API not callable from NodeJS server?
It turns out the "Headers" does not indicate the Headers sent with the request, but the "Headers" HTML Element inside the rich text field. Ensure there's no h1-h6 element in your html_notes can solve this issue.

AWS lambda get http method with Python

I am having difficulty getting http method used in a call to aws lambda via api gateway. I created a REST api in api gateway, which makes a call to a lambda function. In the lambda function I want to have two functions, one for POST requests and one for GET requests. I am unable to get the method from event. In other threads answers are usually for javascript or java only.
I run the following curl command from my terminal:
curl "https://myurl/endpoint"
I also try to send a GET request via advanced rest client.
Here's what I'm trying to do:
def lambda_handler(event, context):
method = event['httpMethod']
if method == "GET":
return get_function()
if method == "POST":
return post_function()
Running the above code results in a keyError.
I have tried this as well:
method = event['requestContext']['http']['method']
I tried printing out the event itself like this method = event. All I get from this is {}, both in the response and in cloudwatch.
How can I read the http method in a request
Below code should work in Python 3.7 runtime. Of course, you can improve the code but, it will give you what you are looking for.
reqcontxt = event.get("requestContext")
httpprtcl = reqcontxt.get("http")
methodname = httpprtcl.get("method")
print('### http method name ###' + str(methodname))
Thanks.
Hiren
With help from #Marcin I understood that I had to tick 'Use Lambda Proxy Integration' option in integration request. Without it my request did not pass any method or headers data to lambda.
It was either this or I would need to add some more code in my application to define the method but as I was using curl for testing I didn't add -X GET nor anything like that to the request.

How to configure or set cookie as json before making a post request in locust load test tool for FastHTTPUser

Locust is having option to use HTTPUser and FastHTTPUser
HTTPUSer internally using python requests which accepts cookies as an argument with json content
e.g. self.client.get(url, header=myheader, cookies=mycookies) here I can configure mycookies as json. Same is not working if I change the code to FastHTTPUser instead of HTTPUser. Need details how to configure hardcoded cookies as key value before making the request in FastHTTPUser approach.
I don't see why you have received downvotes for your question. I found it valid and I think you should create an issue in the locust github page:
https://github.com/locustio/locust/issues/
I think you could solve it like this:
from requests.cookies import cookiejar_from_dict
#task
def task_cookie(self):
cookiejar_from_dict(mycookies, self.client.cookiejar)
self.client.get(url, header=myheader)
I will try to make a PR to make this automatic

How can i get header from request and set it to pytest environment?

I was set for task to write small autotest API. (even though I am a manual junior tester).
The function is:
def test_post_tokens
In this post request I need to get authrization-header from response.
Next I need to pick up this token and insert it into other requests. (or set it to pytest environment). For example:
def test_get_account_info
It is possible to manually set a token for each request, but it takes a lot of time and the hunt to do everything correctly.
In postman, I solved this problem by getting a token in the first request and setting it in an environment
pm.environment.set ("token", postman.getResponseHeader ("Auth-Token"));

How to send POST variables with Nipple on NodeJS

I am trying to use nipple to post to an url within my nodejs application, which itself is running on hapi.js
The documentation essentially doesn't seem to spell it out.
(https://www.npmjs.com/package/nipple)
I tried passing it as payload inside options but that, while not returning an error, returns a 400. Can someone provide a correct example doing a post using nipple?
Essentially, I have two variables that I need to send - let's call the var1 and var2.
Thanks!
That link says that the project has been renamed to wreck. On wreck's github, several of the tests are for a post requests, including this one:
https://github.com/hapijs/wreck/blob/master/test/index.js#L68
If you are still scratching your head, you could also try using curl or postman to sanity check your URL, regardless of any nipple/wreck errors. If that also gives you a 400, nipple/wreck may not be the culprit.

Resources