When programming a QGis plugin, I would like to POST a .json-file to a remote server; preferably using QgsNetworkContentFetcher to do this on the background while waiting for a response.

However, I can't seem to figure out how to configure this as a POST request.

My current code is something like:

def fetch_non_blocking(url, callback, onerror, postData=None):
    fetcher = QgsNetworkContentFetcher()
    def onFinished():
    request = QNetworkRequest(QUrl(url))
    request.setRawHeader("User-Agent","anyways.eu QGIS-plugin")
    request.setRawHeader("Content-Type", "application/json")

which works fine for GET-request, but not a POST

New contributor
Pieter is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Pieter is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.