来自C#的NodeJS发布请求不完整的数据

时间:2019-06-24 12:01:22

标签: c# node.js api post request

我在C#中有一个API,如下所示

        /// <summary>
    /// Runs Supply Plan on Hana DB
    /// </summary>
    /// 
    /// <param name="TaskId"></param>
    /// <param name="ScheduleId"></param>
    /// <param name="TaskType"></param>
    /// <param name="Config"></param>
    [Route("api/Tasks/Hana/Run")]
    [HttpPost]
    public void RunHanaTask(TaskConfig Config)
    {

    }

因此,API需要使用TaskConfig类型的Config参数,该参数定义为

     /// <summary>
    /// Database Connection information
    /// </summary>
    public Connection CN { get; set; }

    /// <summary>
    /// Additional Options
    /// </summary>
    public Dictionary<String, String> Options { get; set; }

因此,当我从POSTMAN调用以下参数时:

{
"TaskId": 10052,
"RunLogId": 417,
"TaskType": "SupplyPlanExec",
"CN": {
    "Name": "Sample",
    "Host": "34.216.234.224",
    "Port": "30013",
    "User": "AXISUSER",
    "Password": "1n5ynCV!",
    "Schema": "ORBIT_3",
    "AppUser": "AXISUSER"
},
"Options": {
    "PlanName": "This is plan name here!"
}

}

从POSTMAN调用API时,API会收到CN和选项,  但是当我使用以下代码从我的nodejs应用程序调用API时:

   request.post(taskObject.remoteURL, { form: postParams }, function (error, response, body) {
    if (response.sstatusCode == 200) {
        deferred.resolve(body);
    } else {
        deferred.reject(error);
    }
})

由于某种原因,CN已成功传递,但未将Options对象传递给API,我一直在努力尝试在NodeJS上尝试这种不同的请求库,但是没有运气。

0 个答案:

没有答案