Skip to main content

Get Custom Field Options from a C# endpoint

  • November 21, 2022
  • 7 replies
  • 697 views

Hi,
I am trying to fetch a few options for a custom field from a C# endpoint.
I know that the response expected is an array of key-value pairs which should have tile & value.

The problem is that it seems that monday can not parse the return string as 1) it is include in quotes as it comes from a C# end point and 2) it contains escaped characters in order to includes quotes.

I don’t get any error in my recipe but the list is always empty.

I have tried with various combinations for escapes characters but I haven’t found a working solution .

Just as an example this is one the return string the endpoint returns in one of my tries.

“"[{\\"title\\":\\"to_upper_case\\",\\"value\\":\\"TO_UPPER_CASE\\"},{\\"title\\":\\"to_lower_case\\",\\"value\\":\\"TO_LOWER_CASE\\"}]"”

Any help will be really appreciated.
Thanks in advance.

7 replies

  • November 21, 2022

Hi @janadel!

How are you trying to fetch these options?


  • Author
  • Participating Frequently
  • November 21, 2022

I am giving a remote options url to my custom field which corresponds to a c# endpoint.


basdebruin
  • Community Expert
  • November 21, 2022

hi @janadel

Monday is not returning a string, the endpoint should return the array in the form (as an example (NodeJS):

var returnArray = [{ title: "Option 1", value: "opt_1" }];

  • Author
  • Participating Frequently
  • November 22, 2022

Hi,
It is a typo, I meant to write the returning string.
My code is
string options = @“[{”“title”“:”“to_upper_case”“,”“value”“:”“TO_UPPER_CASE”“},{”“title”“:”“to_lower_case”“,”“value”“:”“TO_LOWER_CASE”“}]”;
return Request.CreateResponse(HttpStatusCode.OK, options)
I have also tried with with the escaped quote \\" instead of ".

Thanks


basdebruin
  • Community Expert
  • November 22, 2022

Not much experience with C#
Why are you returning a string? You should return an array.


  • Author
  • Participating Frequently
  • November 23, 2022

Thanks for your suggestion. It perfectly worked.
We prefer to return strings instead of the objects believing that we have better control but we don’t.


dipro
Forum|alt.badge.img
  • Leader
  • December 12, 2022

This is why I love our community! Glad y’all found a solution together.