How to format HTTP API call in Javascript?

2019-07-22 08:52发布

I am currently following the etherpad documentation in regards to calling the HTTP API "getText"

How would the API call be structured given these parameters?

Pad content can be updated and retrieved through the API

getText(padID, [rev]) returns the text of a pad 

Example returns:

{code: 0, message:"ok", data: {text:"Welcome Text"}}
{code: 1, message:"padID does not exist", data: null}

1条回答
相关推荐>>
2楼-- · 2019-07-22 09:24

You'll need 2 parameters:

  1. apiKey
  2. padID

The apiKey can be retrieved from a text file named APIKEY.txt in the root of etherpad-lite.

The padID is in the format groupID$padID.

Putting it all together, you can query the pad's content using the following endpoint and payload:

http://pad.domain.com/api/1/getText?apikey=<apiKey>&padID=<padID>

Ex: http://pad.domain.com/api/1/getText?apikey=6b2d257663asddfe8c78f33f94d8e7290asdasd1dea820ea0c37cf42602ea5eef3c&padID=g.fcXsYTpiNlJMwX35$samplePad

查看更多
登录 后发表回答