Adding news via REST API

Added by Adur Seminole about 1 month ago

Can someone provide some (or any) guidance on the XML syntax for news creation via API? Patch #13468. I am new to Redmine. Thanks.

After inspecting the link by Bernhard below, I was able to draft the following code in VBA, but still, I am not able to POST news to my localhost/Redmine.

I wonder what I am doing wrong. My Redmine Install is version 4.1.0.stable.

Example for Creating News

POST /projects/:project_id/news.xml

<?xml version="1.0"?>
<news>
  <title>Sample_title</title>
  <summary>Example</summary>
  <description>Sample Description</description>
</news>

VBA Sample Code

Private Sub News()

    Dim req As New MSXML2.XMLHTTP60
    Dim reqURL As String
    Dim reqBody As String

    reqURL = "http://localhost/redmine/projects/_0000067/news.xml" 
    req.Open "POST", reqURL, False

    req.setRequestHeader "Content-Type", "application/xml" 

    reqBody = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "encoding=" & Chr(34) & "UTF-8" & Chr(34) & " ?>" 
    reqBody = reqBody & "<news>" 
    reqBody = reqBody & "<title>" & "Test_Title" & "</title>" 
    reqBody = reqBody & "<summary>" & "Test_Summary" & "</summary>" 
    reqBody = reqBody & "<description>" & "Test_Description" & "</description>" 
    reqBody = reqBody & "</news>" 

    req.send (reqBody)

End Sub

Replies (1)

RE: Adding News vía Rest Api - Added by Bernhard Rohloff about 1 month ago

I haven't tried the news API, yet. But one can find good examples in the tests for that part. There you have prototypes for all kinds of requests.
source:trunk/test/integration/api_test/news_test.rb

(1-1/1)