working on it

On Monday, March 16, 2020 at 1:57:06 PM UTC+3, Harsh Tibrewal wrote:
>
> I am trying to send a post request in django rest API with mongoengine, 
> while sending a POST request with the following data an 415 status code is 
> returned
>
> {
>   orderId: sample2,
>   restaurantId: cartssj,
>   dateTime: fdsfd,
>   status: pending,
>   cartItems: [
>     {
>       "itemId": "1001",
>       "itemName": "Onion",
>       "requestedQty": "1",
>       "fulfilledQty": "1",
>       "pricePerUnit": "78"
>     },
>     {
>       "itemId": "1002",
>       "itemName": "Potato",
>       "requestedQty": "1",
>       "fulfilledQty": "1",
>       "pricePerUnit": "35"
>     },
>     {
>       "itemId": "1003",
>       "itemName": "Carrot",
>       "requestedQty": "1",
>       "fulfilledQty": "1",
>       "pricePerUnit": "78"
>     },
>     {
>       "itemId": "1004",
>       "itemName": "Toamto",
>       "requestedQty": "1",
>       "fulfilledQty": "1",
>       "pricePerUnit": "90"
>     }
>   ],
>   total: 281.0
> }
>
> the models have been defined as follows ini django:
>
>
> from django.db import models
> from mongoengine import Document,fields,EmbeddedDocument,
> EmbeddedDocumentListField
>
>
> class CartItem(EmbeddedDocument):
>     itemId = fields.StringField(max_length=254,uniique=True)
>     itemName = fields.StringField(max_length=254)
>     requestedQty = fields.StringField(max_length=100)
>     fulfilledQty = fields.StringField(max_length=100)
>     pricePerUnit = fields.StringField(max_length=100)
>
>
>
>
>
>
> class Order(Document):
>     orderId = fields.StringField(max_length=254)
>     restaurantId = fields.StringField(max_length=100)
>     dateTime = fields.StringField(max_length=254)
>     status = fields.StringField(max_length=254)
>     cartItems = fields.EmbeddedDocumentListField(CartItem)
>     total = fields.StringField(max_length=254)
>     meta = {'collection': 'orders'}
>
>
> PLease help me solve this error
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a6529746-9471-4f98-9d4c-bf6b508bb0b3%40googlegroups.com.

Reply via email to