Bug found:Consuming a form URL Encoded REST web service - default input parameter bug

Bug found:Consuming a form URL Encoded REST web service - default input parameter bug

  
When consuming a form URL Encoded web service, and you set a "default value", outsystems will remove your input parameter from the request.^

The following is an example of stripe connect consumed via cURL
Request
curl https://connect.stripe.com/oauth/token \
   -d client_secret=CLIENT_SECRET \
   -d code=AUTHORIZATION_CODE \
   -d grant_type=authorization_code

Response
{
  "token_type": "bearer",
  "stripe_publishable_key": PUBLISHABLE_KEY,
  "scope": "read_write",
  "livemode": false,
  "stripe_user_id": USER_ID,
  "refresh_token": REFRESH_TOKEN,
  "access_token": ACCESS_TOKEN
}


Set the "grant_type" with a default value of "authorization_code", now debug the request by looking at OnBeforeRequest. What you will find here is outsystems has removed the grant_type input parameter name and grant_type value from the form encoded request.

Outsystems sends stripe the following request
client_secret={client_secret}&code={code}

Instead of this request
client_secret={client_secret}&code={code}&grant_type=authorization_code

That is a bug!

The work around solution is to removed the default value, and explicitly specify the grant_type this will solve the problem.


^Note: If you do not specify a value for your input parameter (leave it blank) outsystems will remove your input parameter and its value; this is the correct behaviour. But it is not the correct behaviour to remove an input parameter that has been set with a default value.


Hi Robert,

That is actually what the correct behavior of the "Send default value" property.
It does NOT send the input/value when the value is the same as the default on optional inputs/attributes.
If you want it to always be sent regardless of the value, set it as mandatory or set the send default value to yes.


Regards,
João Rosado
João Rosado wrote:
Hi Robert,

That is actually what the correct behavior of the "Send default value" property.
It does NOT send the input/value when the value is the same as the default on optional inputs/attributes.
If you want it to always be sent regardless of the value, set it as mandatory or set the send default value to yes.


Regards,
João Rosado
Joao

If you set "send default value" to yes, outsystems will always remove the value! regardless if you have set a default value or have specified your own value, no value is ever sent to the web service! 

"If you want it to always be sent regardless of the value, set it as mandatory or set the send default value to yes."

I set the input parameter as optional and "sent default value" to yes, yes means always send my default value to the web service! since it did not do this, the issue has been reported as a bug.

Note: I was running BALI BETA #1 on SQL Server when this behaviour occured, right now I'm running BALI BETA #2 on mySQL Server.
Hi Robert,

Did some tests and could also not replicate what you are reporting :/

Here are my test cases:

A method called TestUrlEncoded_SendNo with all 3 inputs with default values and with "Send Default Values" = No


Then did 3 calls:
 - One with all filled with same values
 - One with all filled with different values
 - One without anything filled


And the results were as expected (only send anything in the method with different values):



Now with all the same but changing "Send Default Values" = Yes:


And the results were also as expected, everything was sent in all requests:



Did I do something different from you?

Regards,
João Rosado
Joao

Firstly thank you for performing the test.

Here is my test results on BALI (BETA 2)

Test #1 -  Assign default value and set “Send Default Value” to yes, default value is sent in the request data! (Success)

 

Test #2 -  Assign default value and set “Send Default Value” to no, assign in code input parameter value, no request data is sent (failed)

I instructed the app not to send the default value, the app did not  send the default value that is good, but it also did not send the input parameter value that I assigned either!

 

 

I get what is happening here!


When I set a value in "Default Value" property, I was expecting that when I set "Send Default Value" to either yes or no, it would control the "Default Value" property above it - Which it does... but it also does something confusing!

However I found out that is not the case, If I assign a value in my code that is of the same value as the default value, outsystems will not send the value to the server! you wouldn't think it would work like that but it does!

Outsystems programmed it like this on purpose?!
Hi Robert,

Yes that is the intended behavior.
As explicitly mentioned in the help page.
http://www.outsystems.com/help/ServiceStudio/9.0/Using_Data/Structure_Attributes_Properties.htm


(humm the table below that quote is a bit incorrect, there just ignore the 2 lines that say "Null Allowed", as they don't apply in REST ...I'll ask for it to be reviewed)

Also the tooltip in Service Studio also explains this fact but not as explicit.


Also I noticed today some issues on an unreleased version of Service Studio that was allowing the "Is Mandatory" = Yes with a "Send Default Value" = No
That combination is supposed to be impossible. Can you check it if your Service Studio is allowing it, as it would justify some of the strange behavious you have been reporting.

Regards,
João Rosado
"Also I noticed today some issues on an unreleased version of Service Studio that was allowing the "Is Mandatory" = Yes with a "Send Default Value" = No"

I reported the issue in BETA 1, but in BETA 2 when you set mandatory to yes, "Send Default Value" is automatically set to "Yes" (this is the correct behavior).

I believe the issue isn't with the code, therefore it is not a software bug! Instead this issue It has to do with me being confused the property "Send Default Value",

When I looked the name and read description of the property ""Send Default Value" it reads "Indicates wheater the input parameter is sent in the request, when it is not mandatory and has a default value set"

It did not tell me that if I specify a "Default value" and set "Send Default Value" to no, and I programmability set my value with the same value as the default value it will not be sent in the request. (Only if the value I specify is different from  the default value it would be sent in the request).

But now I know :-) (Your value that you specify must be different than the default value or it will not be sent in the request.)

Note: Its an issue with the "description" telling me the wrong thing, it is not a bug!






Hi,

Thanks for the feedback.
We will be reviewing both documentation and property tooltip to explain it better.

Regards,
João Rosado