Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NULL values for parameters do not work #1420

Closed
asela-ntt opened this issue Jan 30, 2020 · 10 comments
Closed

NULL values for parameters do not work #1420

asela-ntt opened this issue Jan 30, 2020 · 10 comments

Comments

@asela-ntt
Copy link

Expected Behavior

I want to set a field in the application to NULL and I can use Postman to do it and it works. However, using RestSharp it doesn't work. Expectation is to set the value to null or empty.

Example:
currently in target application;
POBox = PO BOX 1234
I want to make it;
POBox = blank text box

Actual Behavior

The value of the target does not change. Seems like if a parameter is set to a null value it is ignored.

Example:
POBox = PO BOX 1234 stays unchanged after the call.

Steps to Reproduce the Problem

  1. Use the RestClient object to make a request to an end point
  2. Use AddParameter to specify a parameter and set its value to NULL
  3. Use RestClient.Execute to make the call

RestClient client = GetClient();
RestRequest request = new RestRequest("url", Method.PUT);
request.AddParameter("POBox", null);
IRestResponse<Contact> response = client.Execute<Contact>(request);

Specifications

  • Version: 106.3.1
  • Platform: Dot Net Framework

Please feel free to let me know if there are any further information required that could help.

@alexeyzimarev
Copy link
Member

Could you elaborate what "it doesn't work" mean?

@asela-ntt
Copy link
Author

I am calling a rest API that updates a customer record. Customer had a POBox address before and now its changed to a regular address. So I want to set he POBox field to blank. Please see Actual Behaviour section in the above issue description.
So I added the POBox parameter to the call and set it to NULL. (Please see the Steps to Reproduce the Problem section in the issue description) When I make the request I get no errors and the call is successful. However, the value in the POBox field remains unchanged. If I call the same API end point using Postman then I can set the value to NULL and it shows a blank text box in the system. So the API works correctly.
I hope I answered your question. Please let me know if you have any specific questions.

@alexeyzimarev
Copy link
Member

I assume that NULL refers to a missing value. What kind of API are you calling? When you do a request using Postman, how does it look like?

@asela-ntt
Copy link
Author

This is what Postman does. Note it has just mentioned the parameter name and no equal sign because its null.

var client = new RestClient("{baseUrl}?POBox");
client.Timeout = -1;
var request = new RestRequest(Method.PUT);
request.AddHeader("token1", "{token1value}");
request.AddHeader("token2", "{token2value}");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

In your code it seems like you are specifically ignoring null values. Instead I think you should do the same thing like Postman probably.
image

I am hoping that made it clear to you. Let me know if you need further clarifications.

@alexeyzimarev
Copy link
Member

Sorry but I see RestSharp code but where is the Postman request?

@asela-ntt
Copy link
Author

My last comment had the code Postman generated. The first code snippet is that.
Can you please let me know what do you mean when you ask for the Postman Request?
Please provide instructions if possible to get what you are after.

Just to reiterate;
The request.AddParameter() method is not adding the parameter value when the value is null.
I believe this is due to the rest sharp source code:
image

Performing the request through postman works correctly.
The rest sharp code that postman generates is:

var client = new RestClient("{baseUrl}?POBox");
client.Timeout = -1;
var request = new RestRequest(Method.PUT);
request.AddHeader("token1", "{token1value}");
request.AddHeader("token2", "{token2value}");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

The difference here is that the postman generated code does not use the AddParameter method, it adds it directly to the URL.

@alexeyzimarev
Copy link
Member

There's no need to repeat the same information.

I am asking what the request look like in HTTP. You can use, for example, Fiddler, to inspect the request.

@asela-ntt
Copy link
Author

asela-ntt commented Feb 20, 2020

Is this what you wanted?

CONNECT stg.axcelerate.com.au:443 HTTP/1.1
User-Agent: PostmanRuntime/7.22.0
Accept: */*
Cache-Control: no-cache
host: stg.axcelerate.com.au:443
Connection: close

A SSLv3-compatible ClientHello handshake was found. Fiddler extracted the parameters below.

Version: 3.3 (TLS/1.2)
Random: 57 17 61 B7 FE 52 9B A6 9F D2 2E 3A 8A 9E A0 1D 96 36 AA 64 24 17 62 10 A7 69 EC 9B 9C 0A 41 DC
"Time": 30/06/2067 2:48:15 AM
SessionID: empty
Extensions: 
	server_name	stg.axcelerate.com.au
	ec_point_formats	uncompressed [0x0], ansiX962_compressed_prime [0x1], ansiX962_compressed_char2 [0x2]
	supported_groups	x25519 [0x1d], secp256r1 [0x17], secp521r1 [0x19], secp384r1 [0x18]
	SessionTicket	empty
	encrypt_then_mac (RFC7366)	empty
	extended_master_secret	empty
	signature_algs	rsa_pkcs1_sha512, dsa_sha512, ecdsa_secp521r1_sha512, rsa_pkcs1_sha384, dsa_sha384, ecdsa_secp384r1_sha384, rsa_pkcs1_sha256, dsa_sha256, ecdsa_secp256r1_sha256, rsa_sha224, dsa_sha224, ecdsa_sha224, rsa_pkcs1_sha1, dsa_sha1, ecdsa_sha1
Ciphers: 
	[C02F]	TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
	[C02B]	TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
	[C030]	TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
	[C02C]	TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
	[009E]	TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
	[C027]	TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
	[0067]	TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
	[C028]	TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
	[006B]	TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
	[00A3]	TLS_DHE_DSS_WITH_AES_256_GCM_SHA384
	[009F]	TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
	[CCA9]	TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
	[CCA8]	TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
	[CCAA]	TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256
	[C0AF]	TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8
	[C0AD]	TLS_ECDHE_ECDSA_WITH_AES_256_CCM
	[C0A3]	TLS_DHE_RSA_WITH_AES_256_CCM_8
	[C09F]	TLS_DHE_RSA_WITH_AES_256_CCM
	[00A2]	TLS_DHE_DSS_WITH_AES_128_GCM_SHA256
	[C0AE]	TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
	[C0AC]	TLS_ECDHE_ECDSA_WITH_AES_128_CCM
	[C0A2]	TLS_DHE_RSA_WITH_AES_128_CCM_8
	[C09E]	TLS_DHE_RSA_WITH_AES_128_CCM
	[C024]	TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
	[006A]	TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
	[C023]	TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
	[0040]	TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
	[C00A]	TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
	[C014]	TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
	[0039]	TLS_DHE_RSA_WITH_AES_256_CBC_SHA
	[0038]	TLS_DHE_DSS_WITH_AES_256_CBC_SHA
	[C009]	TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
	[C013]	TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
	[0033]	TLS_DHE_RSA_WITH_AES_128_CBC_SHA
	[0032]	TLS_DHE_DSS_WITH_AES_128_CBC_SHA
	[009D]	TLS_RSA_WITH_AES_256_GCM_SHA384
	[C0A1]	TLS_RSA_WITH_AES_256_CCM_8
	[C09D]	TLS_RSA_WITH_AES_256_CCM
	[009C]	TLS_RSA_WITH_AES_128_GCM_SHA256
	[C0A0]	TLS_RSA_WITH_AES_128_CCM_8
	[C09C]	TLS_RSA_WITH_AES_128_CCM
	[003D]	TLS_RSA_WITH_AES_256_CBC_SHA256
	[003C]	TLS_RSA_WITH_AES_128_CBC_SHA256
	[0035]	TLS_RSA_WITH_AES_256_CBC_SHA
	[002F]	TLS_RSA_WITH_AES_128_CBC_SHA
	[00FF]	TLS_EMPTY_RENEGOTIATION_INFO_SCSV

Compression: 
	[00]	NO_COMPRESSION

@asela-ntt
Copy link
Author

Are you clear about the problem when you consider all the information provided in this ticket? Please feel free to let me know if you need anything else. Looking forward to see this getting resolved fast. Thanks.

@alexeyzimarev
Copy link
Member

Should be working in 106.11. Please reopen if the issue still occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants