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(): callback(fetcher.contentAsString()) fetcher.finished.connect(onFinished) request = QNetworkRequest(QUrl(url)) request.setRawHeader("User-Agent","anyways.eu QGIS-plugin") request.setRawHeader("Content-Type", "application/json") fetcher.fetchContent(request)
which works fine for GET-request, but not a POST