REST API CSRF token problem [SOLVED]

I’m actually scripting an automation module for some recurring tasks and am facing a problem.

How can I disable CSRF abuse detection for API calls?
Now after several runs of my python script it returns :

root@:/opt/rt_python/automation# python main.py
ERROR:root: Mon Apr 2 16:57:46 2018 :there is a problem with connection to https://
__/REST/1.0/search/ticket?query=Queue+=+‘testQ’&fields=Subject,CF.{ID}

Everything in the code is 100% right / as i’m an experienced python engineer.
So, any ideas?

Fixed.
Turns out that this was due to a syntax error to the rest api…

Just to be clear, the problem was in the 100% code and not in the REST API?

Well, I don’t remember what was the problem exactly, but indeed that was an API query error, not my code.
So, after a billion of tests I’ve figured out that this wasn’t actually the CSRF token acting against me but a syntax error within the REST API query, I dogged deeper and got that 400 BAD REQUEST.
Another thing witch is very ambiguous was that sometimes when there’s clearly a logical error in the syntax instead of returning an error it dumps the whole list of all open tickets… I still can’t figure this out .