These are chat archives for ushahidi/Community

25th
Jul 2016
Ushbot
@ushbot
Jul 25 2016 11:37
[Mariah, Ushahidi] Hello @ushbot I need your help. I need to get the end point for posting
Ushbot
@ushbot
Jul 25 2016 12:03
[David, Ushahidi] Hi David Ush. Really would appreciate your help with something urgent. Mariah and I need to get the exact API endpoint for Adding a Post. Also we were wondering what headers and response body is needed to pass? You and your team have been a huge help in the past... look forward to hearing from you soon. :)
Ushbot
@ushbot
Jul 25 2016 12:09
[David Losada, Ushahidi] hi Mariah, David, you would need to send a POST request to /api/v3/posts , the usual set of headers: content-type, accept (both set to application/json) and authorization with the bearer token
[Mariah, Ushahidi] Hi @ushbot thanks for your reply
[David Losada, Ushahidi] the body of the POST should be a JSON document, pretty much like what you can see is returned by the API when finding posts
[Mariah, Ushahidi] I will try now
[David, Ushahidi] Thanks a lot David for your quick response.
Ushbot
@ushbot
Jul 25 2016 12:14
[Mariah, Ushahidi] @ushbot Sorry another question can you list the needed parameters to send?
Ushbot
@ushbot
Jul 25 2016 12:24
[David Losada, Ushahidi] Yea I can do, it will just take me some minutes to get to that. Please stay tuned
[Mariah, Ushahidi] Okay thanks!
Ushbot
@ushbot
Jul 25 2016 12:42
[David, Ushahidi] Thanks David...
Ushbot
@ushbot
Jul 25 2016 13:29
[David Losada, Ushahidi] so when I look at the information sent over the wire when creating a post, it looks like this:
{
  "title": "Test title",
  "content": "Test content",
  "form": { ... form description retrieved from /api/v3/forms/:id ... },
  "allowed_privileges": [ "read", "create", "search" ],
  "completed_stages": [],
  "locale": "en_US",
  "published_to": [],
  "status": "draft",
  "tags": [ ... category ids ... ],
  "values": { ... custom fields values if any, coordinates, etc ...}
}
[David Losada, Ushahidi] "tags" and “values" are optional, if you don’t need to make use of categories, coordinates or custom fields
Ushbot
@ushbot
Jul 25 2016 13:35
[Mariah, Ushahidi] Okay @ushbot but I'm getting this error Validation Error
[David Losada, Ushahidi] any detail in that error?
[Mariah, Ushahidi] title:"post.form_id.exists"
[Mariah, Ushahidi] message:"post.form_id.exists"
[David Losada, Ushahidi] mm what are you passing in the form property?
[Mariah, Ushahidi] Nothing yet
[Mariah, Ushahidi] Do I need to pass some params?
[Mariah, Ushahidi] Honestly, I have no idea what to pass in the form array
[Mariah, Ushahidi] object*
[David Losada, Ushahidi] are you familiar with the “surveys” section in the settings?
[David Losada, Ushahidi] that’s where you define the details of the posts you are collecting (extra fields, required fields, validation steps etc)
Ushbot
@ushbot
Jul 25 2016 13:43
[Mariah, Ushahidi] No I'm not
[David Losada, Ushahidi] so each post has to be assigned to a survey
[David Losada, Ushahidi] by default when you install Ushahidi, there’s a survey created with title, description and little more
[David Losada, Ushahidi] I’d recommend…
[David Losada, Ushahidi] best way for your use case is to look at what the browser sends when you create a post with the web application
Ushbot
@ushbot
Jul 25 2016 15:34
[David, Ushahidi] Thanks again David. :)
Ushbot
@ushbot
Jul 25 2016 16:04
[David Losada, Ushahidi] no worries, hope this helps!