1

I've just installed Ballerina version 0.8.0 on Windows. Following the tutorial I tried the echoservice example. Launching the command from the \ballerina-0.8.0\samples\echoService folder

ballerina run service echoService.bal

I received this response

error in ballerina program: value
     at echo(echoService.bal:6)
     at echo(echoService.bal:3)

where the line 6 is

resource echo (message m) {

The example helloworldservice runs propertly.

What's wrong?

Thanks in advance

Gianni

UPDATED 2017-02-26: This is the code I'm executing from ballerina-0.8.0/samples/echoService folder. I'm running it from Git Bash, but it's the same from Command Prompt.

import ballerina.net.http;
@http:BasePath ("/echo")
service echo {

    @http:POST
    resource echo (message m) {
        http:convertToResponse(m);
        reply m;

    }

}

I launch this command

../../bin/ballerina.bat run service echoService.bal

The console shows the same error.

I'm calling the service using Fiddler...

POST http://localhost:9090/echo HTTP/1.1
User-Agent: Fiddler
Host: localhost:9090
Content-Length: 3

sss

...and I receive this response

HTTP/1.1 500 Internal Server Error
Connection: keep-alive
Content-Length: 33
Content-Type: text/plain

error in ballerina program: value
Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105

4 Answers4

1

You should post your entire program. I was able to successfully get it to run as shown on the ballerinalang.org home page.

MattC
  • 31
  • 4
1

This is because you are trying to invoke HTTP POST method without Content-Type. Can you check setting "Content-Type" header to "application/json"

Lakshitha Herath
  • 628
  • 2
  • 9
  • 18
0

This is the echo sample which worked for me.

import ballerina.net.http;
@http:BasePath("/echo")
service echo {
    @http:POST
    resource echo(message m) {
        http:convertToResponse(m);
        reply m;    
    }
}

You can run it by

ballerina run service path/to/echo.bal

from the bin directory, or can do the same via ballerina composer as well.

Nadeeshaan
  • 356
  • 5
  • 15
0

I could reproduce this issue. I used Advanced REST client app in Chrome. I could resolve the error when I set the Content-Type header as follows.

Content-Type: application/x-www-form-urlencoded

Sameera Jayasoma
  • 1,545
  • 8
  • 12