1. ? ?
  2. PowerBuilder
  3. Thursday, 15 April 2021 01:44 AM UTC

long ll_return
RestClient lnv_RestClient
lnv_RestClient = Create RestClient

// Set DataObject
dw_1.DataObject = "d_sq_gr_emp"

// Send request using GET
ll_return = lnv_RestClient.Retrieve(dw_1, "https://demo.appeon.com/PB/webapi_client/employee/102")

// Check the return value
if ll_return >= 0 then
MessageBox("Success", "Rows = " + String(ll_return))
else
MessageBox("Error", "Failed to retrieve data.")
end if

 

 

 

我直接把上面例子网址用浏览器打开,有json数据,有一行,怎么我建立对应datawindow,用上面代码,不能在dw中检索收到数据,谢谢请教

Attachments (2)
? ? Accepted Answer Pending Moderation
  1. Tuesday, 20 April 2021 02:17 AM UTC
  2. PowerBuilder
  3. # 1

还请问下,那怎样能建立服务接口,数据表数据生成json, 给别人去json接口调用?

Comment
  1. Mark Lee @Appeon
  2. Tuesday, 20 April 2021 09:52 AM UTC
不确定你想要什么,给别人调接口,你需要做自己的Web Server。



你可以参考RESTClient object的SendPostRequest的方法看看是不是你想要的

https://docs.appeon.com/pb2019r3/powerscript_reference/ch02s04s694.html



DW 导出Json可以参考如下方法:ExportJson and ExportRowAsJson
  1. Helpful
There are no comments made yet.
? ? Accepted Answer Pending Moderation
  1. Friday, 16 April 2021 03:54 AM UTC
  2. PowerBuilder
  3. # 2

再测试了下,电脑上运行是可以,我之前都是手机app上测试的,还是不行,?手机app运行有什么其它要求吗?

Comment
  1. Mark Lee @Appeon
  2. Friday, 16 April 2021 09:10 AM UTC
是这样子的。

PowerServer Mobile 不支持 RestClient对象。也不支持ImportJson方法。

参考链接如下:

https://docs.appeon.com/ps2020/features_help_for_appeon_mobile/unsupported_objects.html



建议你使用httpclient 来获取相关访问的API link 返回的JSON 字符串,

然后使用appeon_workaorunds.pbl中提供的eon_cjsonnode和eon_cjsonnodearray对象,实现数据窗口export/import json data的功能

这里有个示例demo,参考如下

https://community.appeon.com/index.php/codeexchange/powerserver-web/29-export-data-from-a-datawindow-to-json-and-import-json-data-to-a-datawindow

  1. Helpful
There are no comments made yet.
Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Friday, 16 April 2021 01:23 AM UTC
  2. PowerBuilder
  3. # 3

我觉得是你的网络问题,导致该API访问失败才会出现这个问题。

建议你试试别的电脑上验证一下。

 

参考截图,

另外,你可以看看我附件上视频,该代码是没有问题的。(注意请使用PB 2017 R3 版本或者 更高版本测试)

 

 

Attachments (1)
Comment
There are no comments made yet.
? ? Accepted Answer Pending Moderation
  1. Thursday, 15 April 2021 13:06 PM UTC
  2. PowerBuilder
  3. # 4

还是一样,会不会有其它原因,会不会https这种不行,附件是运行后,返回的结果,还是0行,datawindow也用的是你的附件,  代码就 那几行,到底什么问题?

 

long ll_return
RestClient lnv_RestClient
lnv_RestClient = Create RestClient

// Set DataObject
dw_1.DataObject = "d_sq_gr_emp"

// Send request using GET
ll_return = lnv_RestClient.Retrieve(dw_1, "https://demo.appeon.com/PB/webapi_client/employee/102")

// Check the return value
if ll_return >= 0 then
MessageBox("Success", "Rows = " + String(ll_return))
else
MessageBox("Error", "Failed to retrieve data.")
end if

Attachments (1)
Comment
There are no comments made yet.
Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Thursday, 15 April 2021 07:38 AM UTC
  2. PowerBuilder
  3. # 5

Hi ,

 

这个datawindow d_sq_gr_emp 对象应该参考附件定义。 这样你就可以获取正确的数据。

你可以用附件中的这个对象导入PB,然后重新测试一下。

 

当前你通过这个API获取的返回400错误是因为服务器拒绝访问导致的,该问题已经修复。

 

Regards,

 

Attachments (1)
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.