Config - Source - Save
/config/source/save/{communityId}?json=<source-JSON>
/config/source/save/{communityId} (POST ONLY)
Adds a new source, or updates an existing one, via GET or POST.
Note that it is recommended to test sources before "saving" (adding/updating) them.
Authentication
Required, see Auth - Login
Arguments
communityId (required)
The ID of the community with which you want to associate this source, can also be a regex (community ID - regex) provided that matches only a single community.
json (required for GET methods, not supported for POST methods)
Source object in its JSON representation... see this page for an explanation of the source format, and this set of pages for an overview of the available source ingest functionality.
In the URL/posted JSON, note that:
- If the "key" or "_id" fields are specified, then the "save" is treated like an update, ie the source must already exist.
- The "communityIds" field is ignored, the above URL parameter is used instead.
Examples
Method.Get
http://infinite.ikanow.com/api/config/source/save/4f4b9f8d4f36a94607bd0766?json={...}
Method.Post
Example using curl:
curl -c login_cookie.txt -XPOST 'http://infinite.ikanow.com/api/config/source/save/4f4b9f8d4f36a94607bd0766' -d '{ ... }'
Actionscript
Example Response
{ response: { action: "Source" success: true message: "New source added successfully." time: 10 } }
{ response: { action: "Source" success: true message: "New source added successfully. Note functionally identical sources are also present within your communities, which may waste system resources." time: 10 } data: { // source JSON, including the generated communityIds, key, and _id fields. } }
In this case above, the exact same source (only differing by "display" parameters, owner etc) already exists. It is recommended to delete the source unless you have a specific reason not to.
{ response: { action: "Source" success: true message: "Source updated successfully." time: 10 } }
Error Response
{ response: { action: "Source" success: False message: "Unable to add new source." time: 10 } }
{ response: { action: "Source" success: False message: "Unable to update source." time: 10 } }
Common error messages:
- Unable to serialize Source JSON: indicates that the JSON object POSTED (or passed via URL parameter) is invalid. Try using JSON Lint or a similar tool to debug.
- The source ID is invalid: For update requests, a source "_id" or "key" has been specified that does not match any in the database (this often happens with adding a source where the "_id" or "key" from a different system has been left in).
- User does not have permissions to edit sources shared by this community: You are not the owner of this source, nor a community moderator, nor a system admin.
- (curl/wget returns nothing: Normally an indication that a POST has been used with no URL parameter, or a POST has been used with no content.)