【问题标题】:Nokia's Here Batch Geocoding REST request in NodeJS诺基亚在 NodeJS 中的 Here Batch Geocoding REST 请求
【发布时间】:2017-10-21 22:51:40
【问题描述】:

我正在尝试对 NodeJS 中的批量地理编码执行发布请求。 我正在使用请求库,但由于需要将发布数据作为多行列纯文本数据发送,因此请求失败。

示例帖子数据(使用列分隔符“|”):

recId|searchText|country
0001|Invalidenstraße 116 10115

这是我的要求:

requestPromise.post({
        uri: 'https://batch.geocoder.cit.api.here.com/6.2/jobs',
        qs: {
            app_id: {APP ID}
            , app_code: {APP CODE}
            , action: 'run'
            , mailto: {EMAIL}
            , gen: 8
            , header: true
            , ndelim: '%7C'
            , outdelim: '%7C'
            , outcols: 'displayLatitude,displayLongitude,locationLabel,houseNumber,street,district,city,postalCode,county,state,country'
            , outputCombined: false
        },
        body:'recId|searchText|country\r\n0001|Invalidenstraße 116 10115 Berlin|DEU',
        headers: {
            'Content-Type':'text/plain',
        }

注意这部分,我尝试使用换行符(\r\n):

body:'recId|searchText|country\r\n0001|Invalidenstraße 116 10115 Berlin|DEU'

但我收到此错误消息:

检测到无效的输入标头:[recId|searchText|country]。请修正输入或检查输入分隔符设置。

【问题讨论】:

  • 使用反引号(字符串模板/文字)而不是单引号,删除 \r\n 并在此时按回车键

标签: node.js rest http-post here-api


【解决方案1】:

相信你在 indelim 参数上有错字。

【讨论】:

  • 解决了这个问题 :-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-27
相关资源
最近更新 更多