Forum Discussion

derduher's avatar
derduher
Contributor
12 years ago

How do a create a review through the api?

I am trying to post a review to a product through the api. I don't see any documentation on how to do this. I am looking at the rest docs 12.11 (12.11-release r156815).

 

Also looking for how to mark a review as helpful via api.

6 Replies

  • DougS's avatar
    DougS
    Khoros Oracle
    12 years ago

    Here's the call you need to make to post a review:

     

    /restapi/vc/products/id/{product id}/discussion/reply

     

    I believe the reason behind why it's discussion/reply is that in our object model, each product is associated with a "root" (or "topic") message, and each product review is equivilant to a "reply" to that topic message.

     

    You can find more information about the REST call (what parameters you can pass to the call, etc.) in our REST docs.

     

    I hope that helps!

     

    -Doug

  • derduher's avatar
    derduher
    Contributor
    12 years ago

    Any idea how to mark the review as helpful?

     

    Thanks I see the how to post a review in the docs now.

  • derduher's avatar
    derduher
    Contributor
    12 years ago

    I tried the call you meantioned, for some reason the just added review isn't showing up in products/id/2/reviews

    restapidocs_12_11/Product.html#Product.reviews

     

  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    Hi derduher,

     

    There are a couple of other parameters you'll want to use when adding a review:

    • reviews.review - This parameter should have a value of "true", to set metadata on the message to indicate that it's a review. The post will not show up in the reviews UI without this parameter set to true.
    • review_ratings - You can use this parameter to give a rating along with the review

    For example: 

    /restapi/vc/products/id/my_product_id/discussion/reply?message.subject=test+review&message.body=test+review+body&review_ratings=3&reviews.review=true

     I hope this helps!

  • derduher's avatar
    derduher
    Contributor
    12 years ago

    No dice. The review is still not showing up in products/id/ID/reviews.

     

    1. POST /products/id/2/discussion/reply  restapi.response_format=json&restapi.session_key=XXXXX&product_id=2&message.subject=amazing&message.body=asdf+dfdd+kjkjkdjfkdjfdfk+jasdf+kjkjkdfjkdjfkdjkfjdfkdj+kdd&reviews.review=true
    2. {
          "response": {
              "status": "success",
              "message": {
                  "type": "message",
                  "href": "/boards/id/@review/messages/id/9",
                  "id": {
                      "type": "int",
                      "$": 749
                  },
                  "read_only": {
                      "type": "boolean",
                      "$": false
                  },
                  "subject": {
                      "type": "string",
                      "$": "amazing"
                  },
                  "deleted": {
                      "type": "boolean",
                      "$": false
                  },
                  "author": {
                      "type": "user",
                      "href": "/users/id/155",
                      "login": {
                          "type": "string",
                          "$": "derduher3282013"
                      }
                  },
                  "body": {
                      "type": "string",
                      "$": "asdf dfdd kjkjkdjfkdjfdfk jasdf kjkjkdfjkdjfkdjkfjdfkdj kdd"
                  },
                  "thread": {
                      "type": "thread",
                      "href": "/threads/id/719"
                  },
                  "board": {
                      "type": "board",
                      "href": "/boards/id/@review"
                  },
                  "parent": {
                      "type": "message",
                      "href": "/messages/id/719"
                  },
                  "teaser": {
                      "type": "string",
                      "$": ""
                  },
                  "views": {
                      "count": {
                          "type": "int",
                          "$": 0
                      }
                  },
                  "root": {
                      "type": "message",
                      "href": "/messages/id/719"
                  },
                  "board_id": {
                      "type": "int",
                      "$": 9
                  },
                  "post_time": {
                      "type": "date_time",
                      "$": "2013-04-15T20:31:25+00:00"
                  },
                  "message_rating": {
                      "type": "float",
                      "$": 0
                  },
                  "last_edit_author": {
                      "type": "user",
                      "href": "/users/id/155",
                      "login": {
                          "type": "string",
                          "$": "derduher3282013"
                      }
                  },
                  "kudos": {
                      "count": {
                          "type": "int",
                          "$": 0
                      }
                  },
                  "last_edit_time": {
                      "type": "date_time",
                      "$": "2013-04-15T20:31:25+00:00"
                  }
              }
          }
      }

       

    3. GET /restapi/vc/products/id/2/reviews?restapi.response_format=json

       

    4. {
          "response": {
              "status": "success",
              "product_review_context": {
                  "type": "product_review_context",
                  "count": {
                      "type": "int",
                      "$": 0
                  },
                  "messages": {
                      "message": []
                  }
              }
          }
      }

       

  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    Hi derduher,

     

    That's very strange. I tested the exact call that I posted above on our interal QA sites for the last two releases, and it worked fine for both release versions. I saw the review in both the UI and via the REST API. This suggests to me that perhaps there's something off about your particular community instance, perhaps an admin setting that needs to be tweaked or a back-end config that needs to be changed. I'd suggest filing a case so that our support team can assist in debugging the issue.

     

    I did notice that you added a "product_id" parameter. Perhaps that's throwing it off? Try using the format I posted above and see if that works for you. If not, I'd definitely suggest filing a case.