错误InternalLinkedHashMap <dynamic,dynamic =“”>'不是'Map <string,string =“”>'“类型的子类型

时间:2019-02-01 19:44:31

标签: flutter http-post

我想打电话给我扑应用REST API。因此,其余的api post函数我保存在一个单独的文件中,该函数如下所示。

class process_raw_snowplow_event_data(luigi.Task):
    dataset_date = luigi.DateParameter(default=date.today() - timedelta(days=1))
    # force_run = luigi.BoolParameter()
    _start = luigi.DateSecondParameter(default=datetime.utcnow())
    file_root = luigi.Parameter()


def download_s3_file(self, s3_filename):

    local_filename = "/Users/xxx/etl/%s" % s3_filename

    s3_file_full_path =re.compile("snowplow-enrich-output/enriched/archive/run=" + self.dataset_date.strftime("%Y-%m-%d") +r"-\d{2}-\d{2}-\d{2}/*.")


    try:
        s3.download_file(Bucket=os.environ.get('SP_BUCKET'), Key=s3_file_full_path, Filename=local_filename)
    except Exception as e:
        logger.error("%s - Could not retrieve %s because: %s" % ("download_s3_file()", s3_filename, e))
        raise

从我的调用函数中,我包装了URL以及每个不同api的标头和正文。我的函数调用示例如下。

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/luigi/worker.py", line 199, in run
new_deps = self._run_get_new_deps()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/luigi/worker.py", line 139, in _run_get_new_deps
task_gen = self.task.run()
  File "target.py", line 123, in run
infile_name = self.download_s3_file(s3_filename)
  File "target.py", line 47, in download_s3_file
s3.download_file(Bucket=os.environ.get('SP_BUCKET'), Key=s3_filename, Filename=local_filename)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/boto3/s3/inject.py", line 172, in download_file
extra_args=ExtraArgs, callback=Callback)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/boto3/s3/transfer.py", line 307, in download_file
future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/s3transfer/futures.py", line 73, in result
return self._coordinator.result()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/s3transfer/futures.py", line 233, in result
raise self._exception
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/s3transfer/tasks.py", line 255, in _main
self._submit(transfer_future=transfer_future, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/s3transfer/download.py", line 353, in _submit
**transfer_future.meta.call_args.extra_args
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 314, in _api_call
return self._make_api_call(operation_name, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 612, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found

运行此应用程序时,出现此错误static Future<dynamic> post(String url, {Map headers, body}) { var uri = host + '/api/'+ url; print("uri is :"+uri); return http .post(url, body: body, headers: headers) .then((http.Response response) { final String res = response.body; final int statusCode = response.statusCode; if (statusCode < 200 || statusCode > 400 || json == null) { throw new Exception("Error while fetching data"); } return _decoder.convert(res); }); } 不是'Map'类型的子类型} _fetchDashboardMarkers() async { return NetworkUtils.post("allvh", headers: { 'Authorization': 'Bearer '+authToken }, body: { "fID": 5 }).then((dynamic res) { print("rest return :"+res.toString()); if(res["error"]) throw new Exception(res["error_msg"]); }); } post(url,body:body,headers:headers)`

0 个答案:

没有答案