내 커뮤니티 업적 표시줄을 확대합니다.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

Params are getting picked in shuffled structure from function

Avatar

Level 2

Hi,

Here am trying to use actions has webhook listener and events are triggered from 3rd party where request will be in JSON structure.

When JSON params are picked from function its getting shuffled.

 

ex;

Expected:

"message_delivery_report": {
    "message_id""01FJJY1FJDSKWN22RGMF23ZH5R",
    "conversation_id""01F64Z48R4CD1216GD0CRC0DDK",
    "status""QUEUED_ON_CHANNEL",
    "channel_identity": {
      "channel""Test",
      "identity""XXXXXXX",
      "app_id"""
    },
    "contact_id""01F64Z48P3SPTX11B5B8G410N2",
    "metadata"""
  }
 

Actual: 

"message_delivery_report": {
"channel_identity": {
"app_id": "",
"channel": "Test",
"identity": "XXXXXXX"
},
"contact_id": "01F64Z48P3SPTX11B5B8G410N2",
"conversation_id": "01F64Z48R4CD1216GD0CRC0DDK",
"message_id": "01FJJY1FJDSKWN22RGMF23ZH5R",
"metadata": "",
"status": "QUEUED_ON_CHANNEL"
}

 

 

주제

토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.

5 답변 개

Avatar

Level 2

@duypnguyen Could you please help? I see __ow_body is not present at all, is there any thing am missing on configuration?

Avatar

Employee

@Naveen_Srinivas - regarding the different output order of JSON params, that's expected because it's a JSON object, not an array. So the order doesn't really matter here, because you get an item by `params['keyName'].

For your second question, your action gets a request body in JSON, so it automatically parses it to a JSON object. The "__ow_body" param is only available and useful for non-JSON request body. See https://github.com/apache/openwhisk/blob/master/docs/webactions.md#http-context for more info.

Avatar

Level 2

Thanks for the reply, order matters to me since to authenticate the call we need to encrypt the raw body to match with signature which we will be received from header. Is there any alternate or work around approach to achieve my scenario(I want raw body without shuffled)?

Avatar

Employee

As discussed in direct conversation: it's expected that the order of key-value pairs in a JSON object is not quaranteed. If the library consuming it requires a specific order in the (stringified) JSON object, you could manually construct a raw string with the desired order, taking values from the original request body.

Avatar

Level 2

Yeah, we did requested our vendor to add custom headers to get this request done.