Skip to content

: /api/product.template/: Invalid JSON data: #24

@NirmalaSudhirr

Description

@NirmalaSudhirr

Hi Yezyilomo,
I have been using your repo for last few months. After some code change I was able to login from my flutter app using your odoo-rest-api. I Use postman to play around with the api.
I am able to get result for login api with the below code snippet.

      @http.route('/auth/', 
         type='json', auth='public',methods=["POST"], csrf=False, sitemap=False)
        def authenticate(self, *args, **post):
             ........................................

Next I want to get the product list from odoo. I did bit format to your code like this

       @http.route( '/api/product.template/', auth='user', methods=['GET'], csrf=False)
        def get_product_template(self, model, **params):
        records = request.env[model].search([])
        if "query" in params:
          query = params["query"]
        else:
           query = "{*}"
       record = records.browse(rec_id).ensure_one()
       serializer = Serializer(record, query)
       return http.Response(
        json.dumps(serializer.data),
        status=200,
        mimetype='application/json'
    )

When I try to get response from postman (without passing anything in the body). I get the below error

2020-02-20 08:39:07,874 8663 INFO testodoo odoo.http: /api/product.template/: Invalid JSON data: '' 2020-02-20 08:39:07,875 8663 INFO testodoo werkzeug: 127.0.0.1 - - [20/Feb/2020 08:39:07] "GET /api/product.template/ HTTP/1.1" 400 -

Can you please tell me how could I get product list from odoo using your api?

thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions