The Conversations API lets you programmatically retrieve and submit Bazaarvoice Conversations data for use in your applications. To learn more, go to the Conversations API documentation home page.

Contents

(+ show- hide)

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 HTTP 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 methods

Submissions can use either HTTP GET or HTTP 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 HTTP 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 HTTP Content-Type header:

GET https://[stg.]api.bazaarvoice.com/data/[ContentType].json?ApiVersion=[LatestApiVersion]&Passkey=[YourApiKey]&ProductId=[ProductId]&Action=[SubmissionAction]&Rating=[Rating]&ReviewText=[ReviewText]&Title=[TitleText]&UserNickname=[Nickname]
POST /data/submitreview.json HTTP/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.

Content types

All submissions to the Bazaarvoice platform will be of a particular consumer-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

Story

submitstory.json

Story Comment

submitstorycomment.json

Feedback submission and media 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
ProductId
  • Answer
QuestionId
PRRCategoryId
  • Review Comment
ReviewId
StoryId

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:

  1. Request form information
  2. Preview the author's input
  3. Submit author input to be saved by Bazaarvoice

1. Request form information

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.

3. Submit author input to be saved by Bazaarvoice

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 HTTP/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:

  1. 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.

  2. 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 HTTP/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:

  1. Configure and load a device fingerprint library in your app.
  2. Wait for the script to analyze the user agent and create a device fingerprint.
  3. 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 HTTP GET request or in the body of an HTTP 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:

"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 HTTP POST request.

POST /data/submitreview.json HTTP/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.

Next