stratos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dinithi De Silva <dinit...@wso2.com>
Subject Re: [Error] What is the correct JSON format to add a tenant?
Date Tue, 17 Mar 2015 06:20:32 GMT
Hi Mari,

I have tried the above and it works for me without any issues for the given
json file. As Udara said there must be something missing when copying the
code.

Thanks.

On Tue, Mar 17, 2015 at 11:42 AM, Udara Liyanage <udara@wso2.com> wrote:

> Hi Mari,
>
> I tried the sample and it worked without any issue. Below is my json
> payload. I suspect some characters are missing/mis formatted when you copy
> paste from the page.
>
> udara@puppet:~ $ cat tenant.json
> {
>       "admin":"admin",
>       "firstname":"Frank",
>       "lastname":"Myers",
>       "adminPassword":"admin123",
>       "tenantDomain":"frank.com",
>       "email":"foo@bar.com",
>       "active":"true"
> }
>
>
>
> udara@puppet:~ $ curl -X POST -H "Content-Type: application/json" -d
> @'tenant.json' -k -v -u admin:admin https://localhost:9443/api/tenants
> * Hostname was NOT found in DNS cache
> *   Trying 127.0.0.1...
> * Connected to localhost (127.0.0.1) port 9443 (#0)
> * successfully set certificate verify locations:
> *   CAfile: none
>   CApath: /etc/ssl/certs
> * SSLv3, TLS handshake, Client hello (1):
> * SSLv3, TLS handshake, Server hello (2):
> * SSLv3, TLS handshake, CERT (11):
> * SSLv3, TLS handshake, Server key exchange (12):
> * SSLv3, TLS handshake, Server finished (14):
> * SSLv3, TLS handshake, Client key exchange (16):
> * SSLv3, TLS change cipher, Client hello (1):
> * SSLv3, TLS handshake, Finished (20):
> * SSLv3, TLS change cipher, Client hello (1):
> * SSLv3, TLS handshake, Finished (20):
> * SSL connection using ECDHE-RSA-AES256-SHA384
> * Server certificate:
> *  subject: C=US; ST=CA; L=Mountain View; O=WSO2; CN=localhost
> *  start date: 2010-02-19 07:02:26 GMT
> *  expire date: 2035-02-13 07:02:26 GMT
> *  issuer: C=US; ST=CA; L=Mountain View; O=WSO2; CN=localhost
> *  SSL certificate verify result: unable to get local issuer certificate
> (20), continuing anyway.
> * Server auth using Basic with user 'admin'
> > POST /api/tenants HTTP/1.1
> > Authorization: Basic YWRtaW46YWRtaW4=
> > User-Agent: curl/7.35.0
> > Host: localhost:9443
> > Accept: */*
> > Content-Type: application/json
> > Content-Length: 190
> >
> * upload completely sent off: 190 out of 190 bytes
> < HTTP/1.1 201 Created
> < Date: Tue, 17 Mar 2015 06:07:26 GMT
> < Location: https://localhost:9443/api/tenants/frank.com
> < Content-Type: application/json
> < Transfer-Encoding: chunked
> * Server WSO2 Carbon Server is not blacklisted
> < Server: WSO2 Carbon Server
> <
> * Connection #0 to host localhost left intact
> *{"statusCode":200,"successMessage":"Tenant added successfully: [tenant]
> frank.com <http://frank.com>"*}udara@puppet:~ $
>
> *Tenant exist in the system*
>
> udara@puppet:~ $ curl -X GET  -k  -u admin:admin
> https://localhost:9443/api/tenants | python -m json.tool
>   % Total    % Received % Xferd  Average Speed   Time    Time     Time
>  Current
>                                  Dload  Upload   Total   Spent    Left
>  Speed
> 100   107    0   107    0     0   2011      0 --:--:-- --:--:-- --:--:--
>  2018
> [
>     {
>         "active": true,
>         "createdDate": 1426572445227,
>         "email": "foo@bar.com",
>         "tenantDomain": "frank.com",
>         "tenantId": 1
>     }
> ]
>
>
>
> On Tue, Mar 17, 2015 at 11:31 AM, Mariangela Hills <mariangela@wso2.com>
> wrote:
>
>> Hi Devs,
>>
>>
>> When I executed the JSON given in [1], I get the following errors [2] &
>> [3]. Is the user JSON file correct?
>>
>> [1]
>> https://cwiki.apache.org/confluence/display/STRATOS/4.1.0+Adding+a+Tenant+via+REST+API
>> [2]
>> Admin16s-MacBook-Air:stratos Admin16$ curl -X POST -H "Content-Type:
>> application/json" -d @'/Users/Admin16/Documents/marisamples/user.json' -k
>> -v -u admin:admin https://localhost:9443/api/tenants
>> * About to connect() to localhost port 9443 (#0)
>> *   Trying ::1...
>> * connected
>> * Connected to localhost (::1) port 9443 (#0)
>> * SSLv3, TLS handshake, Client hello (1):
>> * SSLv3, TLS handshake, Server hello (2):
>> * SSLv3, TLS handshake, CERT (11):
>> * SSLv3, TLS handshake, Server key exchange (12):
>> * SSLv3, TLS handshake, Server finished (14):
>> * SSLv3, TLS handshake, Client key exchange (16):
>> * SSLv3, TLS change cipher, Client hello (1):
>> * SSLv3, TLS handshake, Finished (20):
>> * SSLv3, TLS change cipher, Client hello (1):
>> * SSLv3, TLS handshake, Finished (20):
>> * SSL connection using DHE-RSA-AES256-SHA
>> * Server certificate:
>> *  subject: C=US; ST=CA; L=Mountain View; O=WSO2; CN=localhost
>> *  start date: 2010-02-19 07:02:26 GMT
>> *  expire date: 2035-02-13 07:02:26 GMT
>> *  common name: localhost (matched)
>> *  issuer: C=US; ST=CA; L=Mountain View; O=WSO2; CN=localhost
>> *  SSL certificate verify result: unable to get local issuer certificate
>> (20), continuing anyway.
>> * Server auth using Basic with user 'admin'
>> > POST /api/tenants HTTP/1.1
>> > Authorization: Basic YWRtaW46YWRtaW4=
>> > User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0
>> OpenSSL/0.9.8| zlib/1.2.5
>> > Host: localhost:9443
>> > Accept: */*
>> > Content-Type: application/json
>> > Content-Length: 256
>> >
>> * upload completely sent off: 256 out of 256 bytes
>> < HTTP/1.1 400 Bad Request
>> < Date: Tue, 17 Mar 2015 05:53:29 GMT
>> < Content-Type: application/json
>> < Transfer-Encoding: chunked
>> < Connection: close
>> < Server: WSO2 Carbon Server
>> <
>> * Closing connection #0
>> * SSLv3, TLS alert, Client hello (1):
>> {"errorCode":400,"errorMessage":"javax.xml.stream.XMLStreamException:
>> ParseError at [row,col]:[0,28]\nMessage: Expected a ':' after a key at
>> character 28 of {\"tenantInfoBean\":{        \"admin\": \"admin123\",
>>  \"firstname\": \"Frank\",        \"lastname\": \"Myers\",
>>  \"adminPassword\": \"admin123\",        \"tenantDomain\": \"frank.com\",
>>        \"email\": \"foo@bar.com\",        \"active\":
>> \"true\"}}"}Admin16s-MacBook-Air:stratos Admin16$
>>
>> [3] [2015-03-17 11:23:29,953]  WARN
>> {org.apache.cxf.jaxrs.provider.AbstractJAXBProvider} -
>>  javax.xml.stream.XMLStreamException: ParseError at [row,col]:[0,28]
>> Message: Expected a ':' after a key at character 28 of
>> {"tenantInfoBean":{        "admin": "admin123",        "firstname":
>> "Frank",        "lastname": "Myers",        "adminPassword": "admin123",
>>      "tenantDomain": "frank.com",        "email": "foo@bar.com",
>>  "active": "true"}}
>>
>>
>> Regards,
>> Mariangela
>>
>>
>>
>>
>> *--*
>> Mariangela Hills
>> Senior Technical Writer
>>
>> *WSO2, Inc.*lean.enterprise.middleware.
>> m: +94 773 500185
>> w: http://wso2.com
>> <http://wso2.com/events/>
>>
>
>
>
> --
>
> Udara Liyanage
> Software Engineer
> WSO2, Inc.: http://wso2.com
> lean. enterprise. middleware
>
> web: http://udaraliyanage.wordpress.com
> phone: +94 71 443 6897
>



-- 
*Dinithi De Silva*
Associate Software Engineer, WSO2 Inc.
m:+94716667655 | e:dinithis@wso2.com | w: www.wso2.com
| a: #20, Palm Grove, Colombo 03

Mime
View raw message