如何在node.js中发出HTTPS POST请求?

时间:2019-08-09 18:19:22

标签: node.js post https request

如何向API发出HTTPS POST请求。我的代码不起作用,因为它找不到资源。

API文档:https://applymagicsauce.com/documentation,位于身份验证

我的代码无效

STATUS: 415
HEADERS: {"server":"nginx/1.15.10","date":"Fri, 09 Aug 2019 18:22:48 GMT","content-type":"application/json;charset=UTF-8","transfer-encoding":"chunked","connection":"close","x-content-type-options":"nosniff","x-xss-protection":"1; mode=block","cache-control":"no-cache, no-store, max-age=0, must-revalidate","pragma":"no-cache","expires":"0","strict-transport-security":"max-age=15724800; includeSubDomains","x-frame-options":"DENY"}
BODY: {"timestamp":"2019-08-09T18:22:48.981+0000","status":415,"error":"Unsupported Media Type","message":"Content type 'application/octet-stream' not supported","path":"/auth"}

错误消息:await Future.forEach(_paths.entries, (v) async { String uid = Uuid().v1(); StorageReference imgReference = _storageReference.child("Form2").child(uid); StorageUploadTask task = imgReference.putFile( File(v.value) ); StorageTaskSnapshot downloadURL = await task.onComplete; String value = await downloadURL.ref.getDownloadURL(); paths[uid] = value; }

1 个答案:

答案 0 :(得分:0)

看起来您的主机包含一个路径,但是您也提供了一个路径。