Create contact records from CSV
Creates contact records from a CSV file. It imports the CSV text with a header row that specifies the order of these required columns:
A contact might require one or more rows of CSV text to describe it. There is one row for each treatment to be considered. A contact can include more than one treatment. The information in the columns from responseTrackingCode to pathTraversed are repeated. The columns from treatmentId to responseChannel contain unique information per row.
CSV text that is obtained by the counterpart GET action can be used here. The GET action includes an ID column in the output. The import ignores the ID value and a new ID is generated for each contact. Importing the CSV text that is obtained by CSV exporting on the same deployment is not successful because there is a uniqueness constraint violation in the response tracking code value.
In the objectVariables column, each name, value, dataType tuple in the array is represented as a triple tilde separated string and each tuple is separated by a semicolon. The strings cannot contain semicolons.
The responseTrackingCode column cannot be blank.
If the contact already exists, the unique information columns on the rows are used to update the contact. The other columns must carry information identical to what is already recorded. If this condition is not met, the update is rejected.
These are the immutable columns: creationTimeStamp responseTrackingCode subjectId subjectLevel objectUri objectRevisionId objectType objectVariables receiverId receiverRole channel ruleFired pathTraversed abTests treatmentId treatmentRevisionId treatmentGroupId treatmentGroupRevisionId objectNodeId
The input CSV is processed in the order it is received. All contiguous rows with the same responseTrackingCode are considered one section. Those rows are processed according to the description above. It is possible to have the same responseTrackingCode in non-consecutive sections. In that case, the subsequent section is considered updating the contact from the previous section. The service tries to process as many rows as possible.
The output is a multipart/mixed response body. The boundary string of each part is identified in the Content-Type response header. There are three parts in this response.
The first part is for the accepted CSV (header Content-ID: Accepted-CSV). Each contact that was successfully processed is included here. As soon as a contact is created, its rows are streamed back.
The second part is for the rejected CSV (header Content-ID:Rejected-CSV). Each contact that failed processing is identified here. It is in CSV format with the following column order: record number in the entire CSV input, the columns from the input row, and error message. If one line of text has error, all the lines for that contact are rejected. This API prints the first line of the rejected text.
The third part is for global issues (header Content-ID: Global-Issue). It is in CSV format with the following column order: responseTrackingCode or the asterisk value (i.e wildcard for all contacts), global error message that conveys the error that prevents any CSV processing. An example would be the lack of permissions.
1{2 "part1": {3 "contentType": "text/csv; charset=\"utf-8\"",4 "contentId": "Accepted-CSV",5 "body": "4,8815ef75-e45e-4a78-a277-ba8af53c303c,2018-05-13T22:32:30.712Z,VIP.9ea6417c-25d5-4dd7-9377-69881d6563ef,Betty.Monroe.Galloway.18174362195,individual,false,,crt_x,/decisions/flows/525b199b-9073-4359-a521-ff1bc8a59145,e4728fe2-35ce-4ac6-84e0-fd0cad3f0e80,decision,ov1~~~A~~~string;ov2~~~B~~~string,CallCenter.71.310,agent,phone,111101,/ddc3f087-e313-4f63-8404-45a51257df0b/5cb79bb7-1ba2-4c1d-a17c-5d0894ebc046/1111ee7e-7135-4397-bb1d-2aa0a680b9aa,,,29ed1a67-e3be-412c-ae2f-567edd38e086,efb511c1-ad37-4a3d-8a8f-e259d8dc2812,82d4e377-16ab-4165-a923-c38c45cd3a01,2c72fe78-09df-44ff-9039-23f1272390b9,3670f308-fe1a-46b0-96de-b97a09db0be5,false,,,,,"6 },7 "part2": {8 "contentType": "text/csv; charset=\"utf-8\"",9 "contentId": "Rejected-CSV",10 "body": "1,2018-05-13T15:02:40.719Z,GreatCustomer.07f16e7a-db89-400a-91d9-8b6868f07b7b,Francis.Albert.Bacon.19195313421,household,false,,crt_x,/decisions/flows/5c5bc46a-cea0-4102-a88c-71cf1506e2c5,afb62877-64cb-4ae6-bf0c-4e2783a38d3a,decision,ov1~~~A;ov2~~~B,Francis.Albert.Bacon.19195313421,customer,web,00010,/9e4e324b-de68-4035-b511-84cd558d5408/2541ab6e-3e7d-4ba0-8f04-7fc13a8e9794/509c4d2d-dc2c-4cb3-a094-5628e1ec879d,,4f3f14cf-69ed-4d59-9ea2-ecfb525cfa83,7aa86c12-55cf-4e99-8060-5b516314dc44,bc912f15-96a0-4991-ba2a-9f12491cefc0,9d2fccaa-428a-4604-a242-4f259ab8a553,6bf8f1b3-9910-40ad-8146-6affd4f49a1f,true,2018-05-13T15:02:40.719Z,,,,,The value for the objectVariables column is not proper. It must be zero or more groups of name~~~value~~~dataType tuple using semicolon as the delimiter."11 },12 "part3": {13 "contentType": "text/csv; charset=\"utf-8\"",14 "contentId": "Global-Issue",15 "body": ""16 }17}
Name | Type | Required | Description |
---|---|---|---|
If-Unmodified-Since | string | false | Checks to see whether the existing subject contacts identified in the CSV have not been modified since the time specified in the value. If this is not true, the update is not performed. This header is not required when CSV text is used to create contact records. However, this header is required when the CSV text is used to update existing contact records. The value is a timestamp. An appropriate value might be a timestamp that marks a point past the last update of the records to be updated. |
Accept | string | true | In addition to multipart/mixed, also include application/vnd.sas.error+json in the Accept header. The two media types are separated by a comma. If there is a processing error, the error is reported in a JSON error object. In that case, without this arrangement, since the client is expecting only a response of multipart/mixed type, the server uses Http status of 406 to tell the client that it cannot match the expectation because a JSON error object cannot be mapped into a multipart/mixed response. By also accepting application/vnd.sas.error+json, this is avoided. Allowed value: multipart/mixed, application/vnd.sas.error+json |
Status | Meaning | Description | ||
---|---|---|---|---|
200 | OK | The request succeeded. One or more contacts were created. Check the response for any errors. | Headers | Schema |
400 | Bad Request | The request was invalid. | Schema | |
404 | Not Found | No resource exists at the requested path. | Schema | |
406 | Not Acceptable | The media type is incompatible. Occurs when there is an error but the error response media type is not compatible with the multipart/mixed media type. The server returns this status error instead. | Schema | |
412 | Precondition Failed | The `If-Unmodified-Since` request header did not match the resource's last modified timestamp. The resource has changed. The "If-Match" header is not appropriate here because multiple records are included. | Schema | |
428 | Precondition Required | The 'If-Unmodified-Since' header was not sent. The "If-Match" header is not appropriate here because multiple records are included. | Schema |