# Comment Creation

# Create a Comment

The designated endpoint is specifically designed for creating comments on items that have been added to the platform. This endpoint enables users to provide their feedback, opinions, and insights about a particular item, thereby facilitating engaging discussions and enhancing the overall user experience.

To utilize this endpoint, users can send a POST request with the relevant information about the comment they wish to create, including the comment's text, the item it refers to, and the user who created it. The API will then validate the request and add the comment to the platform, assigning it a unique identifier that can be used to retrieve the comment's details.

Once the comment has been added, other users can view it and respond with their own comments, fostering meaningful conversations and enriching the community's engagement.

#

# Request

  • HTTP Method: POST
  • accept : application/json
  • Content Type : application/json
  • Authorization : bearer userjwt
  • URL: https://comments-api-production.up.railway.app/comments/create-comment/?itemid={itemid}

# Params Parameters

Property Type Required Description
itemId number true This is the id of the item

# Body Parameters

Property Type Required Description
text string true This is the user's comment

# Request example

curl -X POST \ 
 'https://comments-api-production.up.railway.app/comments/create-comment/?itemId={itemId}' \ 
-H 'accept : application/json' \ 
-H 'Content-Type : application/json' \ 
-H 'Authorization : bearer userjwt' \ 
 -d  '{ 
"text" : "This is a beautiful headband" 
}' 

# Expected Responses:

# Item Created

You have successfully created an item

{ 
"statusCode":201, 
"responseValue":{ 
"message":"Comment Created Successfully", 
"commentId":101} 
} 
 

# Other Responses:

# Unauthorised Access

You are not allowed to create an item

{ 
"statusCode":401, 
"message":"Unauthorized"} 
 

# Missing Item

This item cannot be found

{ 
"statusCode":404, 
"message":["This item cannot be found"], 
"error":"Not found"} 
 

# Playground

Method: POST

URL: https://comments-api-production.up.railway.app/comments/create-comment/?itemId={itemId}

Headers:

KeyValue
accept
Content-Type
Authorization