Submission Fundamentals
This tutorial explains Conversations API full submission request fundamentals. It does not apply to progressive submission.
Overview
Submission using the Bazaarvoice Conversations API is accomplished by performing an HTTPS request that includes a content type, an API version, your API Passkey and the following:
- subject ID
- API submission action
- author identification
- authenticity information
- author input
Continue reading to learn about each of these submission components and how they are used.
HTTP[s] methods
Submissions can use either HTTPS GET or HTTPS POST depending on the nature of the request. In general, GET will be used to request information about the available submission options or to request a submission preview. The final act of submission, when you are ready for Bazaarvoice to save the author's input, must be performed with POST. When POST is used you must also include the HTTPS ContentType
header with a value of application/x-www-form-urlencoded
. The section The Action
parameter and the submission process will discuss when to use GET or POST in more detail.
The following examples show a GET request as well as a POST request with the HTTPS Content-Type
header:
https://[stg.]api.bazaarvoice.com/data/[ContentType].json?ApiVersion=[LatestApiVersion]&Passkey=[YourApiKey]&ProductId=[ProductId]&Action=[SubmissionAction]&Rating=[Rating]&ReviewText=[ReviewText]&Title=[TitleText]&UserNickname=[Nickname]
/data/submitreview.json HTTPS/1.1
Host: [stg.]api.bazaarvoice.com
Content-Type: application/x-www-form-urlencoded
X-Forwarded-For: [AuthorIPAddress]
...
ApiVersion=[LatestApiVersion]&ProductId=[ProductId]&Action=[SubmissionAction]
&Rating=[Rating]&ReviewText=[ReviewText]&Title=[TitleText]&UserNickname=[Nickname]
&Passkey=[YourApiKey]
Ellipses (...) in above example indicate that your app may generate other headers.
Submission Parameter Notes
- The parameter names and values are all case-insensitive
- The REQUIRED parameter TYPE is used to specify the content type to be submitted, where TYPE = review|question|answer||reviewcomment|
- The REQUIRED parameter FORMAT is used to specify the response format, where FORMAT = json|xml
- The parameters, responses, and error codes for each TYPE are listed on each TYPE's spec page
- The OPTIONAL parameter Callback is only available for preview requests (using HTTPS GET) and using the json response format. See Cross-domain requests section below for more details.
- The Action parameter combined with HTTPS GET or POST determines the how the Bazaarvoice platform will respond:
Action | Description | HTTP[s] Method |
---|---|---|
Action= | Response represents fields necessary to create a submission form. The Action parameter is optional for this operation. | GET, POST |
Action=Preview | Used to validate a submission. Response will include errors on failure. Data will not be stored. | GET, POST |
Action=Submit | On success data will be stored and response will include a submission ID. On failure response will contain errors. | POST |
Action=Submit
may occur without first performing Action=
and Action=Preview
.
Content types
All submissions to the Bazaarvoice platform will be of a particular user-generated content type. Review is the most common content type, but there are others. The table below shows the API endpoint for each content type. Click on an endpoint to see examples, options, and error codes:
Content type | Submission Endpoint |
---|---|
Review | submitreview.json |
Review Comment | submitreviewcomment.json |
Question | submitquestion.json |
Answer | submitanswer.json |
Feedback submission photo upload and video upload have been omitted from this tutorial because they follow different submission patterns than the content types mentioned above.
This example shows a review submission request using submitreview.json
:
GET https://[stg.]api.bazaarvoice.com/data/submitreview.json?ApiVersion=[LatestApiVersion]&Passkey=
[YourApiKey]&ProductId=[ProductId]&Action=[SubmissionAction]&Rating=[Rating]&ReviewText=[ReviewText]
&Title=[TitleText]&UserNickname=[Nickname]
Subject ID
All submissions to the Bazaarvoice platform must identify a subject. For example, reviews and questions are written about products, comments are written in response to reviews, and answers are written in response to questions. The subject's ID is communicated using one of the subject ID parameter keys listed below:
Content types | Subject ID parameter key |
---|---|
- Review - Question | ProductId |
- Answer | QuestionId |
- Review Comment | ReviewId |
NOTE ⏰ : Question can be submitted using
categoryid
only on PRR platform
In this review submission request the subject is a product and the subject ID (the product id) is 123456:
GET https://[stg.]api.bazaarvoice.com/data/submitreview.json?ApiVersion=[LatestApiVersion]&Passkey=
[YourApiKey]&ProductId=123456&Action=[SubmissionAction]&Rating=[Rating]&ReviewText=[ReviewText]&Title=
[TitleText]&UserNickname=[Nickname]`
Subject ID source
ProductId
and CategoryId
are mastered by our clients; they will come from your system. These IDs must not contain the forward-slash character ( / ) and for maximum compatibility we recommend limiting them to alphanumeric characters and the following special characters: asterisk (*), hyphen (-), period (.), and underscore (). You may substitute non-matching characters in your IDs with the closest characters that do match (ex: use "a" instead of "à") or by replacing non-conforming characters with the underscore (ex: replace "/" with "").
ReviewId
, QuestionId
, and StoryId
are created by Bazaarvoice shortly after submission. You can determine those values by making a display request for the appropriate content type. Be aware that content only appears in the API display response after it has been moderated as approved, so do not expect to see content immediately after submission. In staging moderation is automated and will take up to a half hour. In production it is done by human moderators and can take up to 72 business hours, but usually happens faster.
Failure to include a subject ID will result in an error as shown below:
{ "Data": { }, "HasErrors": true, "Form": [ ], "AuthorSubmissionToken": null, "FormErrors": { }, "TypicalHoursToPost": null, "SubmissionId": null, "Locale": null, "Errors": [ { "Message": "400 - ERROR_PARAM_MISSING_SUBJECT_ID", "Code": "ERROR_BAD_REQUEST" } ] }
Subject IDs with a forward slash will result in the following error:
{ "Data": { }, "HasErrors": true, "Form": [ ], "AuthorSubmissionToken": null, "FormErrors": { }, "TypicalHoursToPost": null, "SubmissionId": null, "Locale": null, "Errors": [ { "Message": "Subject ID cannot contain '/'", "Code": "ERROR_PARAM_INVALID_SUBJECT_ID" } ] }
The action parameter and the submission process
Submission to the Bazaarvoice platform is designed to be a three step process:
- Request form information
- Preview the author's input
- Submit author input to be saved by Bazaarvoice
Make a GET or POST request including Action=
(or just exclude Action
). The response will contain field information and meta-data, that can be used to dynamically build a product specific submission form. If an author ID is included, then fields will be pre-populated with known information about that author (Ex: author name).
Both of the following URLs demonstrate valid ways to request form information:
GET https://[stg.]api.bazaarvoice.com/data/submitreview.json?ApiVersion=[LatestApiVersion]&ProductId=
[ProductId]&Passkey=[YourApiKey]
GET https://[stg.]api.bazaarvoice.com/data/submitreview.json?ApiVersion=[LatestApiVersion]&ProductId=
[ProductId]&Passkey=[YourApiKey]&Action=
This step is optional, but the alternative, hard coding the form fields, is fragile and may break when field configurations and their properties are changed.
There will be no error if you forget the
Action
parameter in later steps because omitting it is understood to be a request for form data.
2. Preview the author's input
Make a GET or POST request including Action=preview
and the author's input. In addition to the field information and meta-data from step 1 the response to this request also includes input errors (Ex: missing required fields) as appropriate and the field values are populated with the author's input. This allows you to build a form populated with the author's input and errors as necessary.
This URLs demonstrates how to use the Action
parameter to perform a submission preview:
GET https://[stg.]api.bazaarvoice.com/data/submitreview.json?ApiVersion=[LatestApiVersion]&ProductId=
[ProductId]&Passkey=[YourApiKey]&Action=preview
This step is optional, but if you omit it you should perform submission while the author is available to fix validation errors to ensure content will be accepted. See step #3 for more details.
Make a POST request including Action=submit
and the author's input. If there are input errors, then the response will be identical to a preview request with errors. If there are no errors, then Bazaarvoice will save the data and return a submission ID. You should save the submission ID for your records.
The Bazaarvoice Authenticity Policy forbids modifications to content by anyone other than the original author. If there are content validation errors and the author is not available to correct them, then Bazaarvoice will not accept that content. For this reason, submission to Bazaarvoice should occur as soon as the author has completed their input. This will allow you to give the author an opportunity to fix any validation errors that would otherwise prevent Bazaarvoice from accepting the submission. If you save content to be submitted at a later time, then you should perform a preview request (see step #2) as soon as the author has completed their input, so that you can give them the opportunity to fix any validation errors at that time.
This example demonstrates how to use the Action
parameter to save data in the Bazaarvoice system:
POST /data/submitreview.json HTTPS/1.1 Host: [stg.]api.bazaarvoice.com Content-Type: application/x-www-form-urlencoded X-Forwarded-For: [AuthorIPAddress] ...
ApiVersion=[LatestApiVersion]&ProductId=[ProductId]&Action=submit&Rating=[Rating]&ReviewText
=[ReviewText]&Title=[TitleText]&UserNickname=[Nickname]&Passkey=[YourApiKey]
Ellipses (...) in above example indicate that your app may generate other headers.
Cross Origin Submission
The Conversations API supports Cross Origin Resource Sharing (CORS) to allow JavaScript applications to perform submissions from the browser. The
X-Forwarded-For
header is not necessary when using CORS. Refer to the CORS tutorial to learn more.
Author identification
When submitting content using the Conversations API you will need to identify the author. This is accomplished by submitting an author ID or author email address to Bazaarvoice through one of the authentication methods summarized below:
-
Bazaarvoice-mastered
- Bazaarvoice-mastered authentication, also referred to as 'hosted authentication', allows authors to submit content without prior authentication. In this authentication method Bazaarvoice generates an author ID that is associated with an email address provided during content submission.
-
Client-mastered
- Client-mastered authentication, also referred to as 'site authentication', requires authors to log in using your authentication system before submitting content to Bazaarvoice. In this authentication method the author ID comes from your system and Bazaarvoice stores a copy of it to identify the author.
Learn more at the authentication documentation section.
Authenticity information
All content submitted to the Bazaarvoice platform is evaluated by our risk-based filtering systems to limit fraudulent content and spam from being posted on clients' websites. We require you to submit the author's IP address and a device fingerprint to facilitate this evaluation.
Per the Bazaarvoice Authenticity Policy, you must send a device fingerprint and author IP address attached to each submission. If you fail to send a device fingerprint and author IP address with your submission, Bazaarvoice may take any action deemed necessary in Bazaarvoice’s sole discretion to protect the integrity of the network. Such actions may include but are not limited to: rejection of your content, halting syndication of your content on the Bazaarvoice network, revocation of your API key, or revocation of your API license.
Author IP address
The IP address of a computer initiating an HTTP request (the client) is automatically communicated to the computer receiving the request (the server). If your Conversations API submissions originate from a web-browser or mobile app, we will automatically receive the author's IP address.
However, if you are performing the submission from your server to our server, then you must use the X-Forwarded-For
header to communicate the author's IP address to us. Otherwise, we will receive your server's IP address for every submission, which increases the likelihood that your submissions will be flagged as inauthentic.
In the following example, the IP address 192.0.2.1
represents the IP address of the content author:
POST /data/submitreview.json HTTPS/1.1 Host: stg.api.bazaarvoice.com Content-Type: application/x-www-form-urlencoded X-Forwarded-For: 192.0.2.1 ...
Rating=5&Title=This+is+a+review+TitleText&ReviewText=This+is+review+text.+This+is+review+text.+This+is+review+text.+This+is+review+text.+This+is+review+text.+This+is+review+text.+This+is+review+text.+&UserNickname=bvtester&ProductId=io_bb_callback&UserId=1234567&ApiVersion=[LatestApiVersion]&Action=submit&Passkey=[YourApiKey]
Ellipses (...) in above example indicate that your app may generate other headers.
Device fingerprint
A device fingerprint is an encoded string containing information about a user agent. The technique for generating a device fingerprint varies based on environment and device reputation partner, but in general will involve the following steps:
- Configure and load a device fingerprint library in your app.
- Wait for the script to analyze the user agent and create a device fingerprint.
- Communicate the device fingerprint to Bazaarvoice or one of our reputation management partners.
Read the Device Fingerprinting section for more information and code samples demonstrating how to perform device fingerprinting.
Author input
Author input is communicated to Bazaarvoice using percent encoded key-value pairs in the query component of an HTTPS GET request or in the body of an HTTPS POST request. The parameter keys can be determined from the API response. As previously discussed above, a submission request with Action=
(or no Action=
) will return form metadata, including information about each field. The example below shows how a field is represented in the API submission response. The Id
value isrecommended
(line 8) is the key used for submission:
class="brush: js;">"isrecommended": {
"Default": null,
"MaxLength": null,
"Value": "",
"Required": false,
"Type": "BooleanInput",
"Label": null,
"Id": " isrecommended ",
"MinLength": null,
"Options": [ ]
},
Depending on the type of input, the author will either enter arbitrary values or choose from pre-determined options. In the previous example the input type is BooleanInput
(line 6).
The Conversations API supports the following input types:
Input type | Value source |
---|---|
BooleanInput | Author indicates true or false |
FileInput | Author uploads image or video |
IntegerInput | Author enters number from a pre-determined range |
SelectInput | Author select value from a pre-determined set of options |
TextAreaInput | Author enters arbitrary text and line breaks |
TextInput | Author enters arbitrary text |
This example shows author input being submitted in the body of a HTTPS POST request.
POST /data/submitreview.json HTTPS/1.1 Host: stg.api.bazaarvoice.com Content-Type: application/x-www-form-urlencoded X-Forwarded-For: [AuthorIPAddress] ...
IsRecommended=true&Rating=5&Title=This+is+a+review+TitleText&ReviewText=This+is+review+text.+This+is+
review+text.+This+is+review+text.+This+is+review+text.+This+is+review+text.+This+is+review+text.+This+is
+review+text.+&UserNickname=bvtester&ProductId=123456&UserId=1234567&ApiVersion=[LatestApiVersion]&
Action=submit&Passkey=[YourApiKey]
Ellipses (...) in above example indicate that your app may generate other headers.
Refer to the Input Type tutorial for general information about input types. For information about a specific field refer to the Field Type tutorial.
Response Format for Submission
{
"[CONTENT_TYPE]":{
"[NAME]":"[VALUE]",
...
},
"Data":{
"Field":{
"[FIELD_NAME]":{
"[FIELD_ATTRIBUTE_NAME]":"[FIELD_ATTRIBUTE_VALUE]",
...
},
...
},
"Group":{
"[GROUP_NAME]":{
"[GROUP_ATTRIBUTE_NAME]":"GROUP_ATTRIBUTE_VALUE",
...
"SubElements":\[
{
"Type":"[GROUP_SUBELEMENT_TYPE]",
"ID":"[GROUP_SUBELEMENT_VALUE]"
},
...
]
},
...
}
},
"FormErrors": {
"FieldErrors": {
"[FIELD_ID]" : "[ERROR_MESSAGE]",
...
}
},
"Form":\[
{
"Type":"[TYPE]",
"ID":"[ID]"
},
...
],
"TypicalHoursToPost":[TYPICAL_HOURS_TO_POST]
}
Element | Description |
---|---|
CONTENT_TYPE | Review, Question, Answer, , or Comment. This section contains minimal information about the content being submitted.It contains the basic attributes as Name-Value pairs. |
Data | The Data section contains all the fields and groups that can be submitted. Within each data section (i.e. "Field" or "Group") there is a map of objects keyed by object's id. |
Field | A list of standalone fields e.g. userlocation. The existence of fields is client-configured. |
Group | A list of groups of related fields. The existence of field groups is client-configured. |
Subelements | This section exists for Groups that contain nested groups. |
Form | A list of the fields and groups that are supported for this submission. |
FormErrors | This section exists if there are any errors related to the fields being submitted. e.g. missing fields that are required, invalid values, etc. |
TypicalHoursToPost | The minimum number of hours that it will take for the submitted content to be moderated and available for display. |
Updated 5 months ago