You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
newtabs was built using the values returned from DocuSign.Api.EnvelopeRecipientTabs.recipients_get_recipient_tabs/4. Some fields are nil.
When Poison encodes the model, nil value get serialized to null and the DocuSign API does not like it. It returns this error:
body: "{\r\n\"errorCode\": \"INVALID_REQUEST_BODY\",\r\n\"message\": \"The request body is missing or improperly formatted. Null object cannot be converted to a value type.\"\r\n}",
Since this seems to be specific to DocuSign, I was thinking of adding a transformation in RequestBuilder to prune the nil values in a map. This was taken from a closed Posion issue where someone asked for a way to exclude nil values as a feature in Poison( devinus/poison#55).
@specadd_optional_params(map(),%{optional(atom)=>atom},keyword())::map()defadd_optional_params(request,definitions,[{key,value}]=values)docasedefinitionsdo%{^key=>:body}whenmap_size(definitions)==1-># If there is a single entity to send in the body there is no need to# enclose it in a multipart request.add_param(request,:body,:body,Map.from_struct(value)|>prune_nils())_->do_add_optional_params(request,definitions,values)endend@specprune_nils(map)::mapdefprune_nils(s)whenis_struct(s),do: s|>Map.from_struct()|>Enum.reduce(%{},&reducer/2)defprune_nils(m)whenis_map(m),do: Enum.reduce(m,%{},&reducer/2)@specreducer({any,any},map)::mapdefpreducer({k,v},map)whenis_map(v),do: Map.put(map,k,prune_nils(v))defpreducer({_k,v},map)whenis_nil(v),do: mapdefpreducer({k,v},map),do: Map.put(map,k,v)
Are you OK with this change? I will create a pull request if you are.
The text was updated successfully, but these errors were encountered:
I want to use the API to assign values to recipient tabs in an envelope. So I use something like this:
newtabs
was built using the values returned fromDocuSign.Api.EnvelopeRecipientTabs.recipients_get_recipient_tabs/4
. Some fields are nil.When Poison encodes the model, nil value get serialized to
null
and the DocuSign API does not like it. It returns this error:Since this seems to be specific to DocuSign, I was thinking of adding a transformation in
RequestBuilder
to prune the nil values in a map. This was taken from a closed Posion issue where someone asked for a way to exclude nil values as a feature in Poison( devinus/poison#55).Are you OK with this change? I will create a pull request if you are.
The text was updated successfully, but these errors were encountered: