Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NirmalaSudhirr opened this issue Feb 20, 2020 · 2 comments
Open

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

NirmalaSudhirr opened this issue Feb 20, 2020 · 2 comments

Comments

@NirmalaSudhirr
Copy link

NirmalaSudhirr commented Feb 20, 2020

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

@yezyilomo
Copy link
Owner

I think you're missing something in your JSON request, have you checked if you're sending data in the right format?..

@altanmur
Copy link

Check this @NirmalaSudhirr

#32 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants