-
Re: ¿how to post a message with attachments using jive api?
it2000 Nov 30, 2012 11:52 AM (in response to ricardo.linero)1 person found this helpfulPlease scroll down, Sonny Lau did ask a very similar question a few days ago.
-
Re: ¿how to post a message with attachments using jive api?
ricardo.linero Nov 30, 2012 12:03 PM (in response to it2000)Hi LG.
Maybe you could help me with something more specific about Rest and JSon messages, please see this thread: The specified item was not found., i took a look at the question you talked about and it did no helped much.
-
Re: ¿how to post a message with attachments using jive api?
it2000 Dec 3, 2012 10:23 PM (in response to ricardo.linero)I usually use the v3 API while I suspect that you want to use the v2 API.
For v2 there's the attachment service: REST Reference : Attachment Service.
For v3 there's a bug within discussions, using the API one can not attach documents.
-
Re: ¿how to post a message with attachments using jive api?
ricardo.linero Dec 3, 2012 10:30 PM (in response to it2000)But have you used V2 Api for JIVE 5? i am just starting to send post rest messages using json to my jive 5 instances, this in order to create a discussion, no attachments yet. But when i send the post message nothing happens, here is the request and response.
REQUEST SENDED:
- URL: http://192.168.0.15:8080/contents
- JSONMESSAGE: {"content":{"type":"text/html","text":"Some interesting text to discuss"},"subject":"New Discussion","type":"discussion"}
- HEADERS:
- content-type: application/x-www-form-urlencoded
RESPONSE RECEIVED:
- RESPONSE STATUS LINE: HTTP/1.1 200 OK
- HEADERS:
- Server: Apache-Coyote/1.1
- HEADER ELEMENTS:
- Apache-Coyote/1.1: null
- HEADER ELEMENTS:
- Set-Cookie: jive.server.info="serverName=192.168.0.15:serverPort=8080:contextPath=:localName=192.168.0.15:localPort=8080:localAddr=192.168.0.15"; Version=1; Path=/
- HEADER ELEMENTS
- jive.server.info: serverName=192.168.0.15:serverPort=8080:contextPath=:localName=192.168.0.15:localPort=8080:localAddr=192.168.0.15
- HEADER ELEMENTS
- Set-Cookie: JSESSIONID=1E22FC466D506A8E48E4BF1C45448EB1; Path=/
- HEADER ELEMENTS
- JSESSIONID: 1E22FC466D506A8E48E4BF1C45448EB1
- HEADER ELEMENTS
- X-JAL: 76
- HEADER ELEMENTS
- 76: null
- HEADER ELEMENTS
- Content-Type: text/html;charset=UTF-8
- HEADER ELEMENTS
- text/html: null
- HEADER ELEMENTS
- Transfer-Encoding: chunked
- HEADER ELEMENTS
- chunked: null
- HEADER ELEMENTS
- Date: Thu, 29 Nov 2012 15:43:56 GMT
- HEADER ELEMENTS
- Thu: null
- 29 Nov 2012 15:43:56 GMT: null
- HEADER ELEMENTS
-
Re: ¿how to post a message with attachments using jive api?
it2000 Dec 3, 2012 11:19 PM (in response to ricardo.linero)1 person found this helpful"/contents" looks like a v3 API call. For v2 it should be REST Reference : Space Service
PS: The returned content may be much more interesting than the headers.
-
Re: ¿how to post a message with attachments using jive api?
ricardo.linero Dec 4, 2012 7:18 AM (in response to it2000)Thanks i will give it a try, as for the bug within discussions, using the V3 API, you said that it can not attach documents. I need to support this to my boss with some jive official software document, do you know where can i find that?
-
Re: ¿how to post a message with attachments using jive api?
it2000 Dec 4, 2012 11:42 AM (in response to ricardo.linero)The official JIVE issues are in How would I create a discussion with an attachment from a Jive App?
They are fixed in upcoming versions.
-
-
Re: ¿how to post a message with attachments using jive api?
ricardo.linero Dec 4, 2012 9:13 AM (in response to it2000)I tried sending http://192.168.0.15:8080/application_context/api/core/v2/spaces/1001/discussions but it returned an error saying that can not find that URL, how do i know the ID of the container where i want to create my discussion, is something wrong with this URL besides de ID maybe?
-
Re: ¿how to post a message with attachments using jive api?
it2000 Dec 4, 2012 10:34 AM (in response to ricardo.linero)1 person found this helpfulUse the space service to get some or all spaces: "GET http://domain:port/application_context/api/core/v2/spaces?offset=int&limit=int".
-
Re: ¿how to post a message with attachments using jive api?
ricardo.linero Dec 10, 2012 3:01 PM (in response to it2000)Hi L.G
I tried once again to crate the discussion but now i am getting a 401 html error corresponding to an unauthorized request, i believe it is because of the authentication requirement for this POST operation, here is my three attempts of authentication, maybe you can help me:
1- i used the authentication sevice POST http://domain:port/application_context/api/core/v2/authentication/formlogin and retrieved the JSESSIONID the 201 Status response has, that ID was placed in the header as the documentation says (REST Reference : Authentication Service) in two ways:
First attemp
Second attemp
2- The second way was sending the user and password in the body of the post as a normal parameter
But as you can see i have not been able to get an authorization to create the discussion. Hope you can help me
-
Re: ¿how to post a message with attachments using jive api?
nilsheuer Dec 11, 2012 6:07 AM (in response to ricardo.linero)1 person found this helpfulsee my answer to your other post The specified item was not found.
-
Re: ¿how to post a message with attachments using jive api?
it2000 Dec 11, 2012 7:50 AM (in response to ricardo.linero)If you want to submit cookies you need to set the Cookie header. It must look like "Cookie: JSESSIONID=123; KEY2=VALUE2; KEY3=VALUE3; ..."
Anyhow setting the Basic Auth header is more easy - while it seems to be another undocumented feature. Reading REST Reference : Authentication Service one may think that using the session id is the only and recommended way to use the API.
-
-
-
-
-
-
-
-
Re: ¿how to post a message with attachments using jive api?
ricardo.linero Dec 12, 2012 12:01 AM (in response to ricardo.linero)I finally managed to develop a JAVA method that using the REST API2 from JIVE can create discussions with an attachment.
First of all we need to upload the file to our JIVE instance in order to get a valid URI to reference when creating the discussion, see REST Reference : Attachment Service for more info about it, after sending a request to this attachment service it returns the valid URI as a header of the response now this URI will be the value of the "attachmentURIs" parameter that will be send when consuming the Discussion REST service
To create the discussion we use the Discussion REST service (see REST Reference : Discussion Service), we can send the basic arguments that are: subject, question, html and attachmentURIs; this last parameter is where we reference the URI retrieved from the response when consuming the attachment service. You need to know the ID of the group or space where you want to create the discussion, for that you can use the GET http action over the discussions or spaces service, for example: http://192.168.0.15:8080/api/core/v2/groups?offset=0&limit=25 will return in the response all the info about every group from the jive instances referenced in 192.168.0.15:8080, see REST Reference : Discussion Service and REST Reference : Space Service for more information about the URL structure and other stuff.
Finally our response will look something like this:
POST /api/core/v2/groups/1004/discussions HTTP/1.1
Authorization: Basic YWRtaW46YWRtaW4=
User-Agent: Java/1.7.0_03
Host: localhost:9696
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-type: application/x-www-form-urlencoded
Content-Length: 64
&subject=Testing rest services&html=This is a test&attachmentURIs=http://1923.168.0.15:8080/api/core/v2/attachments/6661&question=true
When you check your JIVE instances you will see the new discussion created in the group with id 1004 for this example:
IMPORTANT: Every POST request you send to consume any REST service from the JIVE API2 must has in its header the basic authentication with the user and password of an authorized JIVE user for this operations. You can see the java code attached in order to get a better idea (HttpReqSender.java file).
Thanks to everyone that helped me with advice and documents
-
HttpReqSender.java.zip 1.5 KB
-
Re: ¿how to post a message with attachments using jive api?
it2000 Dec 12, 2012 9:10 AM (in response to ricardo.linero)1 person found this helpfulReplace "userpassword.getBytes()" with "userpassword.getBytes("UTF-8")". Otherwise you will likely encounter authentication errors when using non-ASCII passwords.
-
Re: ¿how to post a message with attachments using jive api?
ricardo.linero Dec 13, 2012 12:47 PM (in response to it2000)You are so right!
-
-
Re: ¿how to post a message with attachments using jive api?
nilsheuer Dec 13, 2012 1:21 PM (in response to ricardo.linero)You're welcome ;-)
-