我正在使用翻译帮助我用中文回答你。请原谅任何错误。
您是否在上面定义了 “Coin” 或包含 “template”
定义了“Coin”?
Hi @yuan_yan , please try to post your questions in English, we don’t have many native speakers of Mandarin on this forum.
To really diagnose your issue, you’d have to post the error message that you get when hovering over the Coin
keywords. It may simply be that you have not yet defined a template Coin
.
非常感谢您的回复,可以给我一个你的网络联系方式吗?实时的那种,我看你的文档也是翻译软件,我现在想学习,但是英文的确实理解不了。希望你能在线帮我看一下。
Steve Seow via Daml Developers Community <daml@discoursemail.com> 于2021年12月13日周一 16:25写道:
I need to learn from you the calling method of JSON API. Can you give me an example? Format write one
Bernhard via Daml Developers Community <daml@discoursemail.com> 于2021年12月13日周一 16:50写道:
I recently created a learning series on YouTube. Take a look at this episode and see if it helps: Daml 101: BYOF: Bring Your Own Frontend with JSON API [2021] - YouTube
I still don’t quite understand your tutorial. Can you help me write a real example? It’s best to annotate.
Steve Seow via Daml Developers Community <daml@discoursemail.com> 于2021年12月13日周一 20:43写道:
Hi @yuan_yan and welcome to the Daml Developer forum!
Full docs for the JSON API can be found here where you can see how to form requests and what the responses look like.
This browser-based interactive tutorial shows how you can add a UI feature with React that ends up calling the JSON API (as part of our frontend library).
Hope this helps
Why is it prompted that the service cannot be found
Nemanja via Daml Developers Community <daml@discoursemail.com> 于2021年12月14日周二 17:30写道:
Change the url to url = 'http://127.0.0.1:7575/v1/create'
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=757): Max retries exceeded with url: /v1/create/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001F932B284C0>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))
type or paste code here
yes, I had the wrong port number
so the url is url = http://127.0.0.1:7575/v1/create
Fo each request you need to set a bearer token. You can read more about it here and here.
Might be easier to make an example JSON API call via Postman
It should have Bearer
in it, so Authorization: Bearer your_token
(see here)
You are missing the protocol in your url: http://
.
You’re receiving a 401 error, meaning that authentication failed. I’m guessing that the access token doesn’t have the necessary claims in it.
What is that requests
library you are using? It seems odd to me that requests.post
takes just two parameters for url and headers. A POST
usually has data that you are posting, ie I’d expect to have to supply at least a url, data, and then optionally headers.
The structure of a request to create
using the standard fetch
API would look like this:
fetch("http://127.0.0.1:7575/v1/create", {
"headers": {
"authorization": "Bearer TOKEN",
"content-type": "application/json",
},
"body": "{\"templateId\":\"TEMPLATEID\",\"payload\":PAYLOAD}",
"method": "POST",
});