将python代码转换为vb.n

2024-04-30 19:14:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个python代码。我需要vb.net版相当于它。在

提前谢谢。在

payload2 = {"auth_token": "YOUR_AUTH_TOKEN", "status":"green", "data-title1":"index", "data-title2":"machine1", "data-title3":"package10", "data-title4":"current", "data-title5":"tmp"}
r=requests.post("http://localhost:3030/widgets/hot21",data=json.dumps(payload2))

额外信息 代码在“UiPath community edition”中调用

最后一个代码(感谢JussiV)是

^{pr2}$

最后的错误消息是

webservice has thrown an exception
Source: Invoke code
Message: Error compiling code
error BC30035: syntax error. At line 1
error BC30561: 'Formatting' is ambiguous, imported from the namespaces or types 'Newtonsoft.Json, System.Xml'. At line 10
error BC30002: Type 'WebClient' is not defined. At line 12
error BC30451: 'Encoding' is not declared. It may be inaccessible due to its protection level. At line 18
error BC30451: 'Encoding' is not declared. It may be inaccessible due to its protection level. At line 20
Exception Type: ArgumentException

Tags: 代码dataistypelinenotcodeit
1条回答
网友
1楼 · 发布于 2024-04-30 19:14:30

在中创建词典VB.net版https://www.dotnetperls.com/dictionary-vbnet

Dim payload2 As New Dictionary(Of String, String>
payload2.add("auth_token", "<token>")
....

那么post the dictionary as JSON

^{pr2}$

编辑:

您至少缺少具有WebClient类的System.Net的导入。我不确定您导入Newtonsoft.Json的位置/方式,因为我在您的导入中没有看到它,但是基于它被导入到某个地方的错误。在

对于不明确的导入,请参阅this answer以解决不明确的导入。在

相关问题 更多 >