1. ? ?
  2. PowerServer 2020 or older (Obsolete)
  3. Friday, 8 April 2022 01:08 AM UTC

请问下手机端webapi怎样调用,有例子吗,谢谢

? ? Accepted Answer Pending Moderation
  1. Monday, 11 April 2022 02:35 AM UTC
  2. PowerServer 2020 or older (Obsolete)
  3. # 1

服务器地址:http://192.168.99.199:8080/api/exchange

Headers中增加两个节点
Key:ClientID,Value:JJZNLH
Key:ServiceName,Value各接口文档中服务名

 

服务名:
NEZ.AutoTally.ApiService.Base.QueryConfirmResultService

请求参数
{
"StartTime":"2021-07-12 00:00:00", --起始确认时间
"EndTime":"2021-07-12 23:59:00", --截止确认时间
"Vessel":"", --船中文名
"Voyage":"" --航次
}

请求参数限制:
1.起始确认时间、截止确认时间
2.时间间隔大于1天时,船中文名、航次必输

 

请问下,这样带key 的怎样调用呀?我按下面写 不行,不知道怎样加key ,谢谢

Integer li_rc
String ls_ReturnJson
HttpClient lnv_HttpClient
lnv_HttpClient = Create HttpClient
string srq1,srq2,scm,shc
srq1="2021-08-02 00:00:00"
srq2="2021-08-02 23:59:00"
String ls_json
ls_json= '{"StartTime":"'+srq1+'","EndTime":"'+srq2+'","Vessel":"'+scm+'","Voyage":"'+shc+'"}'
messagebox("",ls_json)
// Constructs a POST request (supports all headers)
lnv_HttpClient.SetRequestHeader("Content-Type", "application/json;charset=UTF-8")
// Content-Length header set by SendRequest

// Sends request using POST method (to add the string data to the body and set to the Content-Length header)
li_rc = lnv_HttpClient.SendRequest("POST","http://192.168.99.199:8080/api/exchange", ls_json)

// Obtains the response data
if li_rc = 1 and lnv_HttpClient.GetResponseStatusCode() = 200 then
lnv_HttpClient.GetResponseBody(ls_ReturnJson)
messagebox("","ok")
messagebox("",ls_ReturnJson)
else
messagebox("","no")
end if

Comment
  1. Kai Zhao @Appeon
  2. Monday, 11 April 2022 05:04 AM UTC
PB应用中可以成功吗?服务是做什么用的,认证吗?其他工具可以调用API成功吗?请提供其他工具成功的代码参考。建议咨询服务提供商,作为header是否可以,具体格式如何。
  1. Helpful
There are no comments made yet.
? ? Accepted Answer Pending Moderation
  1. Monday, 11 April 2022 00:04 AM UTC
  2. PowerServer 2020 or older (Obsolete)
  3. # 2

服务名:
NEZ.AutoTally.ApiService.Base.QueryConfirmResultService

请求参数
{
"StartTime":"2021-07-12 00:00:00", --起始确认时间
"EndTime":"2021-07-12 23:59:00", --截止确认时间
"Vessel":"", --船中文名
"Voyage":"" --航次
}

请求参数限制:
1.起始确认时间、截止确认时间
2.时间间隔大于1天时,船中文名、航次必输

 

你好,上面这样的怎样调用呀?谢谢

Comment
There are no comments made yet.
? ? Accepted Answer Pending Moderation
  1. Friday, 8 April 2022 02:01 AM UTC
  2. PowerServer 2020 or older (Obsolete)
  3. # 3

看不懂呀,能提供个例子吗?或者针对上面能指导怎样 写吗?谢谢

? ? Accepted Answer Pending Moderation
  1. Friday, 8 April 2022 01:32 AM UTC
  2. PowerServer 2020 or older (Obsolete)
  3. # 4

你好,我按你方法可以调用了,但返回的是json,  我手机端怎样解析取到 附件里面标记黄色部分,谢谢

下面是返回的json字符串

{

    "status": 0,

    "message": "query ok",

    "request_id": "d4261cd8-b6d9-11ec-9dc6-246e964f9a82",

    "result": {

        "location": {

            "lat": 28.715725,

            "lng": 117.999507

        },

        "address": "江西省上饶市玉山县S306",

        "formatted_addresses": {

            "recommend": "玉山县临湖镇岭下村",

            "rough": "玉山县临湖镇岭下村"

        },

        "address_component": {

            "nation": "中国",

            "province": "江西省",

            "city": "上饶市",

            "district": "玉山县",

            "street": "S306",

            "street_number": "S306"

        },

        "ad_info": {

            "nation_code": "156",

            "adcode": "361123",

            "city_code": "156361100",

            "name": "中国,江西省,上饶市,玉山县",

            "location": {

                "lat": 28.539515,

                "lng": 118.343094

            },

            "nation": "中国",

            "province": "江西省",

            "city": "上饶市",

            "district": "玉山县"

        },

        "address_reference": {

            "street_number": {

                "id": "",

                "title": "",

                "location": {

                    "lat": 28.801813,

                    "lng": 117.989334

                },

                "_distance": 489.2,

                "_dir_desc": "东"

            },

            "town": {

                "id": "361123105",

                "title": "临湖镇",

                "location": {

                    "lat": 28.729725,

                    "lng": 117.938759

                },

                "_distance": 0,

                "_dir_desc": "内"

            },

            "street": {

                "id": "15897088507094390441",

                "title": "S306",

                "location": {

                    "lat": 28.801813,

                    "lng": 117.989334

                },

                "_distance": 489.2,

                "_dir_desc": "东"

            },

            "landmark_l2": {

                "id": "3531832548728165799",

                "title": "岭下村",

                "location": {

                    "lat": 28.71286,

                    "lng": 117.996147

                },

                "_distance": 457.3,

                "_dir_desc": "东北"

            }

        }

    }

}

Attachments (1)
Comment
  1. Kai Zhao @Appeon
  2. Friday, 8 April 2022 01:51 AM UTC
你好,

请使用appeon_workarounds.pbl中提供的eon_cjsonnode和eon_cjsonnodearray对象解析JSON数据,详请参考.

https://docs.appeon.com/ps2020/workarounds_and_api_guide/Accessing_JSON_format_Data.html

Regards,Kai
  1. Helpful
There are no comments made yet.
Kai Zhao @Appeon Accepted Answer Pending Moderation
  1. Friday, 8 April 2022 01:12 AM UTC
  2. PowerServer 2020 or older (Obsolete)
  3. # 5

你好,

请尝试使用httpclient对象调用Web API,比如:

Integer li_rc
String ls_string
HttpClient lnv_HttpClient
lnv_HttpClient = Create HttpClient

// Sends request using GET method
li_rc = lnv_HttpClient.SendRequest("GET", "https://demo.appeon.com/PB/webapi_client/employee/102")
// Obtains the response data
if li_rc = 1 and lnv_HttpClient.GetResponseStatusCode() = 200 then
lnv_HttpClient.GetResponseBody(ls_string)
end if

destroy lnv_HttpClient

messagebox('', ls_string)

 

Regards,
ZhaoKai

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.