Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1793 มุมมอง

Hi, I believe this to be a different issue to my other posts however it does involve my beloved webhooks. Im still trying to get them working and understand them.

So, what I have is:

1) postman send:

{ "id": 1, "name": "fred"}

----------------------------------------

2) The code to execute:

try:

    data = request.get_json_data()

except:

    data = str(request.get_http_params())


id = data[0]

message = data[1]

note = id,message


env['mail.message'].create({

    'author_id': 2,

    'model': 'project.task',

    'res_id': 1,

    'body': note,

    'message_type': 'comment',

    'subtype_id': 2,

})

----------------------------------------

3) The output in "todo" chatter (project.task)

('{', '}')

----------------------------------------

After testing, I found that the try was failing and therefore the except was executing. 

No matter how I sliced "data" there were only 2 elements data[0] was "{" and data[1] was "}". Anything else through and exception. 

So, it appears to me that, putting the fact that the request.get_json_data() did not run, why would the request.get_http_params() not contain the parameters pass in?

Can anyone enighten me on what is going on here?

Once again, thank you so, so much for reading and help.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,
Adjust below variables as follows:

id = data[0]

message = data[1]

Change the above to

id = payload['id']

message = payload['message]

Thanks

อวตาร
ละทิ้ง
ผู้เขียน

Wow, so all those vids I've been watching which tell us to use the request.get_json_data() are not that useful if all the data is already in payload.
Yet again, you are the GOAT Niyas.

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ม.ค. 25
908
Webhooks - Create a lead แก้ไขแล้ว
1
ต.ค. 24
2870
2
มี.ค. 25
1887