SOCIAL TABLES 504 response when add guest to guest_list - social-tables

I follow tutorial
Please tell, why when i try send post request i receive 504 error ?
But if i send from from api console https://developer-portal.socialtables.com/api-console it`s work fine
I send request from python
headers :
'Accept': 'application/json', 'Authorization': 'Bearer valid token'
guest list is valid
token is valid
get requests work fine
POST /4.0/guestlists/{guestlist_id}/guests
python 3.7.2 with lib requests==2.21.0 urllib3==1.24.1
r = requests.post('https://api.socialtables.com/4.0/guestlists/965d8450-daf3-
11e9-9e6a-1fbad5325279/guests', data=json.dumps({
"id":"1231231231","first_name":"fname","last_name":"lname","email":"aa#aaa.aa"
}))
r.status_code # 504
r.text # ''
r.method # post
r.url
'https://api.socialtables.com/4.0/guestlists/965d8450-daf3-11e9-9e6a-1fbad5325279/guests'

Sorry it`s works without json.dumps(dict())
working example:
r = requests.post('https://api.socialtables.com/4.0/guestlists/965d8450-daf3-
11e9-9e6a-1fbad5325279/guests', data={
"id":"1231231231","first_name":"fname","last_name":"lname","email":"aa#aaa.aa"
})

Related

github API check_runs returning 415, "Unsupported Media Type"

really that simple, making a request with github api: https://docs.github.com/en/rest/reference/checks#list-check-runs-for-a-git-reference
I am trying to find the check runs for a particular branch I have. Below is the url I GET from:
url = ...api/v3/repos/{repo_fullname}/commits/{branch}/check-runs'
Here are my headers:
headers = {
'Authorization': 'token ' + token,
"Accept": "application/vnd.github.v3+json"
}
I get hit with the: 415 Client Error: Unsupported Media Type for url...
Please help, been banging my head for hours. Thanks!
Perhaps you could try a different accept? I work with octokit for node and this fixed my problem, maybe it would help in this case.
headers = {
'Authorization': 'token ' + token,
"Accept": "application/vnd.github.antiope-preview+json"
}

Http with token in Ionic 4

(Sorry for my bad english) I have to access an api, with a token that they have provided me. My problem is that I don't know how to implement it, after searching and searching, it gives me the following error:
Access to XMLHttpRequest at 'https://www.presupuestoabierto.gob.ar/api/v1/credito' from origin 'http://localhost:8100' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
I pass my code to you, to indicate that it is wrong in the definition of the token (the x instead of the token) and eventually in the CORS policy, thank you very much!
const headers = { 'Authorization': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': 'http://localhost:8100'}
this.http.get<any>('https://www.presupuestoabierto.gob.ar/api/v1/credito', { headers }).subscribe(data => {
this.datos = data.blabla;
})
Headers should pass like this in Ionic- Angular. Make sure that you have a service file.Visit this link to know more about services:
https://angular.io/tutorial/toh-pt4
let headers = new Headers({
'Content-Type' : 'application/json',
'Auth':authvalue
});
return this.http.get(url,options).pipe(map(res => res.json()));

Cookie authentication error using Python requests

I am trying to POST a request to Kibana using the "/api/console/proxy" path.
I have 3 headers in my request:
es_headers = {
'kbn-version': "5.5.0",
'Content-Type': "application/json",
'Cookie': "session_2=eyJhbGciOi....(long string)"
}
I am using Python requests as following:
session = requests.Session()
r = session.post(url, timeout=15, data=json.dumps(body), headers=es_headers)
From "Postman" it works just fine, but from my Python script I get a [200] response but the content of the response is like this:
'Error encountered = Unable to decrypt session details from cookie. So
clearing it.'
I googled this response but couldn't find any info about it (which is weird ...)
Any help appreciated here
Thanks
Try including the cookies separately from the headers, like this:
import requests
es_headers = {
'kbn-version': "5.5.0",
'Content-Type': "application/json",
}
session = requests.Session()
session.cookies.update({'Cookie': "session_2=eyJhbGciOi....(long string)"})
r = session.post(url, timeout=15, data=json.dumps(body), headers=es_headers)
hope this helps

Sending axios get request with authorization header

I have tried to send axios get request using vue.js and it worked just fine when there was no need to send headers. However, when it was required to send an authorization jwt, i was getting CORS error: "Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource." I don't know why is this problem occurring since there is Access-Control-Allow-Origin: '*' header in the response. My code is the following:
axios.get(url, {
headers: {
'Authorization': 'Bearer TOKEN'
}
})
.then(function (response) {
console.log(response.data)
})
The weirdest thing is when I use querystring.stringify or JSON.stringify on the header, I don't get the error 403(forbidden), but just an error 401 - Unauthorized. I tried with variable and with the token itself and it didn't work.
I tried to send a post request in order to get a web token with required data - username an password and it worked. I was able to get the token.
I made a whole bunch of research the last two days on this and I found different kind of request structure and configs which I tried all of them, but none were efficient. Is there a way to check if the request is being send with the header? Is something else the problem? If someone can help, I would appreciate. Thanks.
I think you should add this code to the bootstrap.js (or where the axios is defined):
window.axios = require('axios'); // I think its already added
window.axios.defaults.headers.common = {
'X-Requested-With': 'XMLHttpRequest'
};
You didn't mention, but I guess you use laravel, or other framework, what is protected from csrf attack, thats why you need to add the generated token to your ajax request header.

Testing external API's using Angular 2 & Apache

I am trying to make an HTTP requeset to an external API using the following request:
let headers = new Headers({
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/x-www-form-urlencoded',
'Access-Control-Allow-Origin': "*"
});
let options = new RequestOptions({ headers: headers });
let body = JSON.stringify({
test: test
comments: "test"
});
this.http.post("EXTERNAL_API_URL", body, options)
.map(res => res.json())
.subscribe((data) => {
console.log(data);
});
When I am making the API call from Chrome Postman plugin, the API works without any problem.
When I'm trying to make this call from my angular 2 app, the call is not working and returns the following error:
XMLHttpRequest cannot load MY_API_URL. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
I know that I can access bypass it using the no web-security chrome:
Chrome.exe --disable-web-security
But I wish to make it work without it...
I also tried to add Header set Access-Control-Allow-Origin "*" in my http.conf as described here.
Any ideas?