paulschneider / b247-api

0 stars 0 forks source link

Endpoint register not working, wf-staging #66

Closed benvium closed 10 years ago

benvium commented 10 years ago

When I try to access the register endpoint by posting:

{"firstName":"abc","lastName":"def","email":"ben+1@calvium.com"}

to /v1/register

I get:

{"error":true,"message":"Required field(s) first_name, last_name, nickname, email, password is missing or empty"}
paulschneider commented 10 years ago

Can you send me an error log for this one? I've just tried it and its working for me:

{
    "success": {
        "message": "Resource successfully created.",
        "statusCode": 201,
        "method": "POST",
        "endpoint": "v1/register",
        "time": 1407767541,
        "data": {
            "user": {
                "id": 1,
                "accessKey": "79F82A6BFCA6815",
                "firstName": "David",
                "lastName": "Scholes",
                "email": "david@yepyep.co.uk"
            }
        }
    },
    "source": [
        {
            "platform": "OS X",
            "browser": "Chrome"
        }
    ]
}
paulschneider commented 10 years ago

That message you are getting actually looks like the user/preference endpoint response. Hmmm...

benvium commented 10 years ago

raw output from my curl command:

== Info: Adding handle: conn: 0x7fd162803a00
== Info: Adding handle: send: 0
== Info: Adding handle: recv: 0
== Info: Curl_addHandleToPipeline: length: 1
== Info: - Conn 0 (0x7fd162803a00) send_pipe: 1, recv_pipe: 0
== Info: About to connect() to wf-staging.co.uk port 80 (#0)
== Info:   Trying 81.27.85.121...
== Info: Connected to wf-staging.co.uk (81.27.85.121) port 80 (#0)
=> Send header, 144 bytes (0x90)
0000: POST /v1/register HTTP/1.1
001c: User-Agent: curl/7.30.0
0035: Host: wf-staging.co.uk
004d: Accept: */*
005a: Content-Type: application/json
007a: Content-Length: 73
008e: 
=> Send data, 73 bytes (0x49)
0000: {"firstName":"Foo","lastName":"Bar","email":"ben+1407766867@calv
0040: ium.com"}
== Info: upload completely sent off: 73 out of 73 bytes
<= Recv header, 26 bytes (0x1a)
0000: HTTP/1.1 400 Bad Request
<= Recv header, 37 bytes (0x25)
0000: Date: Mon, 11 Aug 2014 14:21:06 GMT
== Info: Server Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips mod_bwlimited/1.4 PHP/5.4.28 is not blacklisted
<= Recv header, 94 bytes (0x5e)
0000: Server: Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips 
0040: mod_bwlimited/1.4 PHP/5.4.28
<= Recv header, 26 bytes (0x1a)
0000: X-Powered-By: PHP/5.4.28
<= Recv header, 21 bytes (0x15)
0000: Content-Length: 113
<= Recv header, 19 bytes (0x13)
0000: Connection: close
<= Recv header, 32 bytes (0x20)
0000: Content-Type: application/json
<= Recv header, 26 bytes (0x1a)
0000: X-Pad: avoid browser bug
<= Recv header, 2 bytes (0x2)
0000: 
<= Recv data, 113 bytes (0x71)
0000: {"error":true,"message":"Required field(s) first_name, last_name
0040: , nickname, email, password is missing or empty"}
== Info: Closing connection 0
{"error":true,"message":"Required field(s) first_name, last_name, nickname, email, password is missing or empty"```
paulschneider commented 10 years ago

I think you've missed the sub-domain off of the base URL. If I call http://wf-staging.co.uk/v1/register with my registration params I get the same error message you given above.

The API is of course http://api.wf-staging.co.uk/v1/

I'll see if I can catch this issue and prevent you posting to something that shouldn't be possible.

benvium commented 10 years ago

Yes, that's it. Thanks Paul! I'm surprised it responded at all without that.

paulschneider commented 10 years ago

This is because David has set the serverName in the apache config to wf-staging.co.uk. Which means the endpoint you called is a valid domain.

I'll look into why it seemingly gave you the preferences response though. Its on my list.

benvium commented 10 years ago

Thanks Paul. If it had given a 404 I'm sure I'd have noticed my mistake, sorry for the bother though.