title: Using API to create a new query on Redash
body: <p>I managed to import queries into another account. I used the endpoint POST function given by Redash, it sort of just applies to just “modifying/replacing”: <a href="https://github.com/getredash/redash/blob/5aa620d1ec7af09c8a1b590fc2a2adf4b6b78faa/redash/handlers/queries.py#L178" rel="nofollow noreferrer">https://github.com/getredash/redash/blob/5aa620d1ec7af09c8a1b590fc2a2adf4b6b78faa/redash/handlers/queries.py#L178</a></p>
  
  <p>So actually, if I want to import a new query what should I do? I want to create a new query that doesn’t exist on my account. I’m looking at <a href="https://github.com/getredash/redash/blob/5aa620d1ec7af09c8a1b590fc2a2adf4b6b78faa/redash/handlers/queries.py#L84" rel="nofollow noreferrer">https://github.com/getredash/redash/blob/5aa620d1ec7af09c8a1b590fc2a2adf4b6b78faa/redash/handlers/queries.py#L84</a></p>
  
  <p>Following is the function which I made to create new queries if the query_id doesn’t exist.</p>
  
  <p>url = path, api = user api, f = filename, query_id = query_id of file in local desktop</p>
  
  <pre><code>def new_query(url, api, f, query_id):
      headers ={'Authorization': 'Key {}'.format(api), 'Content-Type': 'application/json'}
      path = "{}/api/queries".format(url)
      query_content = get_query_content(f)
      query_info = {'query':query_content}
      print(json.dumps(query_info))
      response = requests.post(path, headers = headers, data = json.dumps(query_info))
      print(response.status_code)
  </code></pre>
  
  <p>I am getting response.status_code 500. Is there anything wrong with my code? How should I fix it?</p>