使用SQL代码调用webapi的教程原创
金蝶云社区-马上出炉
马上出炉
4人赞赏了该文章 155次浏览 未经作者许可,禁止转载编辑于2024年11月28日 14:18:24

SQL调用webapi.png

代码:

DECLARE @Object as Int

Exec sp_OACreate 'WinHttp.WinHttpRequest.5.1', @Object OUT;

DECLARE @LoginResultType INT

declare @ServiceUrl as varchar(1000)

set @ServiceUrl = 'http://192.168.1.233/k3cloud/Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc'

DECLARE @data varchar(max);

set @data='{"acctID": "66a4611abce743","username": "T1","password": "T1.3333322","lcid": 2052}'

Declare @ResponseText AS  varchar(8000);     

Exec sp_OAMethod @Object, 'open', NULL, 'POST',@ServiceUrl,'false'

Exec sp_OAMethod @Object, 'setRequestHeader', NULL, 'Content-Type','application/json;charset=UTF-8'

Exec sp_OAMethod @Object, 'send', NULL, @data

Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT

SET @LoginResultType=JSON_VALUE(@ResponseText,'$.LoginResultType')

SELECT '用户验证消息:'+@ResponseText

IF @LoginResultType=1

BEGIN

SET @data='{"formId":"PRD_MO","opNumber":"UnAudit","data":{"Numbers":"MO_2408050007"}}'

SET @ServiceUrl='http://192.168.1.233/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExcuteOperation.common.kdsvc'                              Exec sp_OAMethod @Object, 'open', NULL, 'POST',@ServiceUrl,'false'

Exec sp_OAMethod @Object, 'setRequestHeader', NULL, 'Content-Type','application/json;charset=UTF-8'

Exec sp_OAMethod @Object, 'send', NULL, @data

Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT

Exec sp_OADestroy @Object

SELECT @ResponseText

END




图标赞 4
4人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!