C Sharp script deployed in Azure not working

Hello Experts,

I have deployed the following C# script in Azure, however I'm constantly getting the following error when I enter the firstname and lastname parameters as shown in the image


       
using System.Net;
        public static async Task<HttpResponseMessage> 
        Run(HttpRequestMessage req, TraceWriter log)
        {
            string firstname=null,lastname = null;
            dynamic data = await req.Content.ReadAsAsync<object>();
            firstname = firstname ?? data?.firstname;
            lastname = data?.lastname;
            return (lastname + firstname) == null ? 
             req.CreateResponse(HttpStatusCode.BadRequest, 
             "Please pass a name on the query string or in the 
             request body") : 
            req.CreateResponse(HttpStatusCode.OK, "Hello " + 
             firstname + " " + lastname);
        }

Open in new window


The following is the error message@

2017-11-27T16:37:37.340 Function started (Id=a7a78773-bf61-44b3-999a-3792ac4dd28f)2017-11-27T16:37:37.351 Function compilation error2017-11-27T16:37:37.351 run.csx(11,14): error CS1010: Newline in constant2017-11-27T16:37:37.351 run.csx(11,64): error CS1003: Syntax error, ',' expected2017-11-27T16:37:37.351 run.csx(12,22): error CS1003: Syntax error, ',' expected2017-11-27T16:37:37.351 run.csx(12,26): error CS1003: Syntax error, ',' expected2017-11-27T16:37:37.351 run.csx(12,26): error CS1010: Newline in constant2017-11-27T16:37:37.351 run.csx(12,31): error CS1003: Syntax error, ',' expected2017-11-27T16:37:37.351 run.csx(14,41): error CS1026: ) expected2017-11-27T16:37:37.351 run.csx(14,41): error CS1003: Syntax error, ':' expected2017-11-27T16:37:37.351 run.csx(14,41): error CS1525: Invalid expression term ';'2017-11-27T16:37:37.351 run.csx(12,14): error CS0103: The name 'request' does not exist in the current context2017-11-27T16:37:37.351 run.csx(12,22): error CS0103: The name 'body' does not exist in the current context2017-11-27T16:37:37.607 Exception while executing function: Functions.RegisterUser. Microsoft.Azure.WebJobs.Script: Script compilation failed.2017-11-27T16:37:37.670 Function completed (Failure, Id=a7a78773-bf61-44b3-999a-3792ac4dd28f, Duration=324ms)

Open in new window


The following is an image of the inputs
csharp
Can someone please let me know where I'm going wrong?

Thanks

Carlton
LVL 1
Member_2_7966113Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Snarf0001Commented:
If you still need help with this, it's just the line break in the prompt field "Please pass xxxx".  You're breaking onto a new line, so you either have to terminate the string and use a "+" symbol, or prefix the string with "@":

using System.Net;
        public static async Task<HttpResponseMessage> 
        Run(HttpRequestMessage req, TraceWriter log)
        {
            string firstname=null,lastname = null;
            dynamic data = await req.Content.ReadAsAsync<object>();
            firstname = firstname ?? data?.firstname;
            lastname = data?.lastname;
            return (lastname + firstname) == null ? 
             req.CreateResponse(HttpStatusCode.BadRequest, 
             "Please pass a name on the query string or in the request body") : 
            req.CreateResponse(HttpStatusCode.OK, "Hello " + 
             firstname + " " + lastname);
        }

Open in new window


OR:

using System.Net;
        public static async Task<HttpResponseMessage> 
        Run(HttpRequestMessage req, TraceWriter log)
        {
            string firstname=null,lastname = null;
            dynamic data = await req.Content.ReadAsAsync<object>();
            firstname = firstname ?? data?.firstname;
            lastname = data?.lastname;
            return (lastname + firstname) == null ? 
             req.CreateResponse(HttpStatusCode.BadRequest, 
             @"Please pass a name on the query string or in the 
             request body") : 
            req.CreateResponse(HttpStatusCode.OK, "Hello " + 
             firstname + " " + lastname);
        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Member_2_7966113Author Commented:
Snarf

Thanks for responding. I'm just about to board a flight so I will try your suggestion when I land.

Will let you know how I get on when I land.

Cheerd
0
Member_2_7966113Author Commented:
Snarf,

Fantastic. The code worked like a dream. Cheers mate.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.