一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

redmine,通過代碼修改創(chuàng)建提交記錄 附件等 API with curl

 ala咪s 2017-04-15

Using the REST API with cURL?

curl is a command-line tool for transferring data using various protocols. It can be used to interact with the Redmine REST API.

Using JSON

Here is a simple example of a command that can be used to update an issue:

curl -v -H "Content-Type: application/json" -X PUT --data-binary "@388.json" -u login:password http://redmine/issues/388.json
curl -v -H "Content-Type: application/json" -X PUT --data-binary "@388.json" -H "X-Redmine-API-Key: xxxx" http://redmine/issues/388.json

The file that contains the data sent to Redmine (388.json in the example above) would look like this:

{
  "issue": {
    "subject": "subject123",
    "notes": "Changing the subject" 
  }
}
Note: it's required to set the Content-Type header according to the format of the data you are sending. It must be set to one the following values:
  • application/json
  • application/xml

Using XML

Here is a simple example of a command that can be used to create an issue with custom fields:

curl -v -H "Content-Type: application/xml" -X POST --data-binary "@issue.xml" -u login:password http://redmine/issues.xml
curl -v -H "Content-Type: application/xml" -X POST --data-binary "@issue.xml" -H "X-Redmine-API-Key: xxxx" http://redmine/issues.xml

Where issue.xml content is:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<issue>
  <subject>API custom fields</subject>
  <project_id>1</project_id>
  <tracker_id>2</tracker_id>
  <custom_fields type="array">
    <custom_field>
      <id>2</id>
      <value>Fixed</value>
    </custom_field>
    <custom_field>
      <id>1</id>
      <value>0.8.2</value>
    </custom_field>
  </custom_fields>
</issue>

Text formatting

If you want to use some text formatting (e.g to update a wiki page on your project), you should make sure to use curl's option --data-binary instead of --data to load the file. Only that way, curl will send newline characters unchanged and will retain all formatting.

curl -v -H "Content-Type: application/xml" -X PUT --data-binary "@wiki.xml" -u login:password http://redmine/projects/foo/wiki/page_test.xml

Where wiki.xml content is:

<?xml version="1.0"?>
<wiki_page>
<text>
h1. TITLE

 %{font-size:14pt}SUBTITLE%
</text>
</wiki_page>

Attaching files

If you want to create an issue with image.png attached, you need to upload this file first:

curl --data-binary "@image.png" -H "Content-Type: application/octet-stream" -X POST -u login:password http://redmine/uploads.xml

# 201 response
<upload>
  <token>7167.ed1ccdb093229ca1bd0b043618d88743</token>
</upload>

Then, use the token to create the issue:

curl -v -H "Content-Type: application/xml" -X POST --data-binary "@issue.xml" -u login:password http://redmine/issues.xml

Where issue.xml content is:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<issue>
  <subject>Issue with attachment</subject>
  <project_id>1</project_id>
  <uploads type="array">
    <upload>
      <token>7167.ed1ccdb093229ca1bd0b043618d88743</token>
      <filename>image.png</filename>
      <content_type>image/png</content_type>
    </upload>
  </uploads>
</issue>

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    观看日韩精品在线视频| 亚洲国产丝袜一区二区三区四| 日韩精品第一区二区三区| 91香蕉视频精品在线看| 日本一品道在线免费观看| 国产美女网红精品演绎| 狠狠干狠狠操在线播放| 日本欧美一区二区三区在线播| 亚洲精品熟女国产多毛| 国产亚洲午夜高清国产拍精品| 极品熟女一区二区三区| 爱草草在线观看免费视频| 国产精品蜜桃久久一区二区| 国产精品色热综合在线| 亚洲中文字幕人妻系列| 国产成人在线一区二区三区| 国产又粗又黄又爽又硬的| 丰满熟女少妇一区二区三区| 国产精品一区二区视频成人| 香蕉尹人视频在线精品| 欧美日韩免费观看视频| 欧美午夜一级特黄大片| 欧美日韩欧美国产另类| 肥白女人日韩中文视频 | 亚洲熟女熟妇乱色一区| 激情丁香激情五月婷婷| 亚洲女同一区二区另类| 国产高清精品福利私拍| 亚洲精品伦理熟女国产一区二区 | 区一区二区三中文字幕| 亚洲综合日韩精品欧美综合区| 精品国产91亚洲一区二区三区| 日本黄色录像韩国黄色录像| 日韩精品一区二区亚洲| 高清一区二区三区四区五区| 国产精品香蕉免费手机视频| 九九热在线视频观看最新| 日韩欧美好看的剧情片免费| 久久中文字人妻熟女小妇| 亚洲av熟女国产一区二区三区站| 老司机精品视频免费入口|