Thread overview
Debugging bad requests with vibe
Feb 08, 2018
Nicholas Wilson
Feb 08, 2018
Nicholas Wilson
Feb 09, 2018
Nicholas Wilson
Feb 09, 2018
Seb
Feb 09, 2018
Nicholas Wilson
Feb 09, 2018
Arjan
Feb 09, 2018
tetyys
Feb 09, 2018
Nicholas Wilson
Feb 09, 2018
rjframe
February 08, 2018
I have set up a vibe.d rest interface (on a server) and have a client on my machine.

struct Observation
{
    string desc;
    DateTime time;
}

interface Obsever
{
    @property void observe(Observation ra);
}

void main()
{
    auto test = Observation("a duck", cast(DateTime)Clock.currTime(UTC()));

    auto client = new RestInterfaceClient! Obsever("http://example.com/observation");
    client. observe = test; // 400
}

I' pretty sure the url is correct because other ones give 404.

Is there a way I can see/log what requests are being made? I can change both the client and server.

February 08, 2018
On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote:
> I have set up a vibe.d rest interface (on a server) and have a client on my machine.
>
> struct Observation
> {
>     string desc;
>     DateTime time;
> }
>
> interface Obsever
> {
>     @property void observe(Observation ra);
> }
>
> void main()
> {
>     auto test = Observation("a duck", cast(DateTime)Clock.currTime(UTC()));
>
>     auto client = new RestInterfaceClient! Obsever("http://example.com/observation");
>     client. observe = test; // 400
> }
>
> I' pretty sure the url is correct because other ones give 404.
>
> Is there a way I can see/log what requests are being made? I can change both the client and server.

Never mind, it was because I was accidentally shadowing that path with a get on the server.
February 09, 2018
On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote:
> Is there a way I can see/log what requests are being made? I can change both the client and server.

-v and -vv
February 09, 2018
On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote:
> On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote:
>> Is there a way I can see/log what requests are being made? I can change both the client and server.
>
> -v and -vv

All that gives me is a bunch of
[FAC3BFF6:FAC451F6 dia] Actively closing TCP connection

is there a way to get the JSON being sent?
February 09, 2018
On Thursday, 8 February 2018 at 20:24:19 UTC, Nicholas Wilson wrote:
> On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote:
>> I have set up a vibe.d rest interface (on a server) and have a client on my machine.
>>
>> struct Observation
>> {
>>     string desc;
>>     DateTime time;
>> }
>>
>> interface Obsever
>> {
>>     @property void observe(Observation ra);
>> }
>>
>> void main()
>> {
>>     auto test = Observation("a duck", cast(DateTime)Clock.currTime(UTC()));
>>
>>     auto client = new RestInterfaceClient! Obsever("http://example.com/observation");
>>     client. observe = test; // 400
>> }
>>
>> I' pretty sure the url is correct because other ones give 404.
>>
>> Is there a way I can see/log what requests are being made? I can change both the client and server.
>
> Never mind, it was because I was accidentally shadowing that path with a get on the server.

Hmm, nope it wasn't that.
February 09, 2018
On Friday, 9 February 2018 at 11:46:31 UTC, Nicholas Wilson wrote:
> On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote:
>> On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote:
>>> Is there a way I can see/log what requests are being made? I can change both the client and server.
>>
>> -v and -vv
>
> All that gives me is a bunch of
> [FAC3BFF6:FAC451F6 dia] Actively closing TCP connection
>
> is there a way to get the JSON being sent?

Wireshark?
February 09, 2018
On Friday, 9 February 2018 at 11:46:31 UTC, Nicholas Wilson wrote:
> On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote:
>> On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote:
>>> Is there a way I can see/log what requests are being made? I can change both the client and server.
>>
>> -v and -vv
>
> All that gives me is a bunch of
> [FAC3BFF6:FAC451F6 dia] Actively closing TCP connection
>
> is there a way to get the JSON being sent?

Try Fiddler, great tool too
February 09, 2018
On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote:
> On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote:
>> Is there a way I can see/log what requests are being made? I can change both the client and server.
>
> -v and -vv

So it turns out that structs do not work as parameters TO rest interface functions.

https://github.com/vibe-d/vibe.d/issues/2067
February 09, 2018
On Fri, 09 Feb 2018 15:48:54 +0000, Nicholas Wilson wrote:

> On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote:
>> On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote:
>>> Is there a way I can see/log what requests are being made? I can change both the client and server.
>>
>> -v and -vv
> 
> So it turns out that structs do not work as parameters TO rest interface functions.
> 
> https://github.com/vibe-d/vibe.d/issues/2067

I have a project doing this; I think I solved that (or something) with:

```
@path("/api/")
interface RestAPI {
    // stuff
}
```

I cannot reproduce your problem with that code though to see if it will work.