-2

I need to set below request body in a http rest callout which is working fine in postman.

[{ "notification_type": "complaints", "notification_mode": "push", "notification_title": "", "notification_message": "test notification with V0321E", "message_title": "", "message_body": "test message title with V0321E", "vendor_ids": [ "V0321E" ], "meta_data": null, "tags": "" }] 

So basically I'm setting below request body in apex as below and it's not working[Basically it's getting 403 exception from the server which is returning 200 from postman. ].

map<string, object> reqBody = new map<string, object>{ 'notification_type' => 'complaints' , 'notification_mode' => 'push', 'notification_title' => 'test' , 'notification_message' => 'test message' , 'message_title' => 'test' , 'message_body' => 'test body' , 'vendor_ids' => new List<String> {'V0321E'}, 'tags' => '' }; 

Really appreciate any help on this.

Thanks, Prasad

2
  • 2
    What does "It's not working" mean? Please edit your post to provide complete details of behavior and any errors verbatim. Since your Postman request body and your Apex don't even use the same set of fields, it's not clear that one result informs the other. Commented May 21, 2021 at 2:21
  • Sure @David, Basically it's getting 403 exception from the server which is returning 200 from postman. Commented May 21, 2021 at 3:01

1 Answer 1

1

You didn't make it a list:

list<object> reqBody = new List<Object> { new map<string, object>{ 'notification_type' => 'complaints' , 'notification_mode' => 'push', 'notification_title' => 'test' , 'notification_message' => 'test message' , 'message_title' => 'test' , 'message_body' => 'test body' , 'vendor_ids' => new List<String> {'V0321E'}, 'tags' => '' } }; 
1
  • thank you very much @sfdcfox, this is the exact thing I need. Commented May 21, 2021 at 3:02

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.