Open p1p3dream opened 4 years ago
conf.custom_headers() is empty in the from_endpoint method even when populated. I'm looking at it to see if I can figure out a simple fix in a pull request.
Modifying the from_endpoint method in headers to include an X-Requested-By fixed it for me.
@bobloki a PR would be great, thank you!
After further investigation, my issue was caused by multiple .sparkmagic folders and multiple config.json files. I'm not sure how I got to have this many of them. Maybe after a long time of working with this project or different installations over time?
I had a sparkmagic folder at the C:\ and another in two different user folders, Three total.
This method in livyreliablehttpclient.py is the method that grabs the headers. For me this now works.
@staticmethod
def from_endpoint(endpoint):
headers = {"Content-Type": "application/json" }
headers.update(conf.custom_headers())
retry_policy = LivyReliableHttpClient._get_retry_policy()
return LivyReliableHttpClient(ReliableHttpClient(endpoint, headers, retry_policy), endpoint)
conf.custom_headers() contained the correct headers with the following format after pulling them from the config.json
"custom_headers": {"Content-Type": "application/json", "X-Requested-By" : "blah.blah.com"},
I was getting the 400 error Missing Required Header for CSRF protection, when trying to add an endpoint. I added the X-Requested-By Header in livyreliablehttpclient, headers variable, and in reliablehttpclient too for good measure.
I am able to successfully add the endpoint now, but when I try to create session is throwing the same 400 CSRF error. I imagine its something I'm doing wrong, but not sure where to go from here.