-2

I have a syntax error
under parameter type is the red lines and error message
Where there is a red underline there is this message: Types of parameters that cn be added to request
CS1003: Syntax error. "," Expected how can I correct the code?

request.AddParameter("application/json", "query",
               "{" +
                   "\"cabinet\":\"Posteingang\"," +
                   "\"name\":\"Posteingang\"," +
                   "\"objectTypeId\":\"2\"," +
                   "\"fields\":{" +
                   "\"Eingangsdatum\":{\"value\":\"" + DateTime.Now.ToString("dd.MM.yyyy") + "\"}" +
                   "}" +
               "}" ParameterType.RequestBody);

IRestResponse response = client.Execute(request);

List<SearchResult> searchResults1 = JsonConvert.DeserializeObject<List<SearchResult>>(response.Content);

Console.WriteLine(response.Content);
GSerg
  • 71,102
  • 17
  • 141
  • 299
NB4K
  • 15
  • 2

1 Answers1

1

you have

request.AddParameter("application/json", "query",
        "{" +
            "\"cabinet\":\"Posteingang\"," +
            "\"name\":\"Posteingang\"," +
            "\"objectTypeId\":\"2\"," +
            "\"fields\":{" +
            "\"Eingangsdatum\":{\"value\":\"" + DateTime.Now.ToString("dd.MM.yyyy") + "\"}" +
            "}" +
        "}" ParameterType.RequestBody);

But you are missing a comma before "ParameterType"

So it should be

request.AddParameter("application/json", "query",
        "{" +
            "\"cabinet\":\"Posteingang\"," +
            "\"name\":\"Posteingang\"," +
            "\"objectTypeId\":\"2\"," +
            "\"fields\":{" +
            "\"Eingangsdatum\":{\"value\":\"" + DateTime.Now.ToString("dd.MM.yyyy") + "\"}" +
            "}" +
        "}", ParameterType.RequestBody);

Just a piece of advice on syntax errors: The code editor is normally more than capable enough of helping you out with those types of errors and explaining where they are and why they are there. So just double-check the code you've written and READ what the text says. (Welcome btw)

https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs1003

  • 1
    It's not about "dislike helping with syntax.", my reading is: You are never writing answers for OP. But for all future reader. What does a future reader have to type in his search engine to find them. The only possible common denominator is to have something like [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/) for "CS1003 Error". But that question cannot be build up into cannonical. – Drag and Drop Feb 22 '21 at 13:36
  • I see your reasoning @DragandDrop, I think I might've just had a bad experience with reading some answers :P Ill edit my post to better reflect the reasoning – Gideon Botha Feb 22 '21 at 19:06