MerryFairyTalesAD440 / API

1 stars 2 forks source link

Unauthorized error returned #44

Closed mviencek closed 5 years ago

mviencek commented 5 years ago

Tried to use your curl command and an error was returned. Curl command used -

curl -X POST -d "{ 'id':'0', 'title' : 'Cinderella','description' : 'childrens book','author':'random author' }" -v -i "https://ad4401boxfransprint263s2plkbwxejg.azurewebsites.net/api/writeDoc"

Response received -

C:\Users\mvien>curl -X POST -d '{ curl: no URL specified! curl: try 'curl --help' for more information

C:\Users\mvien> "id":"0", The filename, directory name, or volume label syntax is incorrect.

C:\Users\mvien> "title" : "Cinderella", '"title"' is not recognized as an internal or external command, operable program or batch file.

C:\Users\mvien> "description" : "children'\''s book", '"description"' is not recognized as an internal or external command, operable program or batch file.

C:\Users\mvien> "author":"random author" The filename, directory name, or volume label syntax is incorrect.

C:\Users\mvien>curl -X POST -d "{ 'id':'0', 'title' : 'Cinderella','description' : 'childrens book','author':'random author' }" -v -i "https://ad4401boxfransprint263s2plkbwxejg.azurewebsites.net/api/writeDoc" Note: Unnecessary use of -X or --request, POST is already inferred.

FrancescoWard commented 5 years ago

Thank you @mviencek for reporting this issue. The function auth. level has been switched to "Anonymous". Please try again if possible. Thanks & regards, Francesco

mviencek commented 5 years ago

Still returns a 404 error

curl -X POST -d "{ 'id':'0', 'title' : 'Cinderella','description' : 'childrens book','author':'random author' }" -v -i "https://ad4401boxfransprint263s2plkbwxejg.azurewebsites.net/api/writeDoc"

Microsoft Windows [Version 10.0.17763.316] (c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\mvien>curl -X POST -d "{ 'id':'0', 'title' : 'Cinderella','description' : 'childrens book','author':'random author' }" -v -i "https://ad4401boxfransprint263s2plkbwxejg.azurewebsites.net/api/writeDoc" Note: Unnecessary use of -X or --request, POST is already inferred.

FrancescoWard commented 5 years ago

HI @mviencek , Are you running on Win64 ? Can you please try the following from Windows cmd prompt (escaping the double quotes)?

curl -X POST -d "{ 
 'id':'0', 
 'title' : 'Cinderella', 
 'description' : 'childrens book', 
'author':'random author' 
}" -v -i "https://ad4401boxfransprint263s2plkbwxejg.azurewebsites.net/v1/writeDoc"

Thanks, Francesco

mviencek commented 5 years ago

the content of a post should have nothing to do with a 404 error unless you set it up that way the curl command you sent me does not compile

see below

C:\Users\mvien>curl -X POST -d '{ \"id\":\"0\", \"title\" : \"Cinderella\", \"description\" : \"children'\''s book\", \"author\":\"random author\" }' -v -i 'https://ad4401boxfransprint263s2plkbwxejg.azurewebsites.net/v1/writeDoc' Note: Unnecessary use of -X or --request, POST is already inferred.

mviencek commented 5 years ago

you dont have to escape quotes you just go to ' inside of "

FrancescoWard commented 5 years ago

Hi @mviencek, thank you for this. Can you please try the command above again (I changed the quotes :-)) here's what I get :

wfrs06$ curl -X POST -d "{ 
>  'id':'0', 
>  'title' : 'Cinderella', 
>  'description' : 'childrens book', 
> 'author':'random author' 
> }" -v -i "https://ad4401boxfransprint263s2plkbwxejg.azurewebsites.net/v1/writeDoc"
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 13.66.226.80...
* TCP_NODELAY set
* Connected to ad4401boxfransprint263s2plkbwxejg.azurewebsites.net (13.66.226.80) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: CN=*.azurewebsites.net
*  start date: Dec 17 12:40:47 2017 GMT
*  expire date: Dec 17 12:40:47 2019 GMT
*  subjectAltName: host "ad4401boxfransprint263s2plkbwxejg.azurewebsites.net" matched cert's "*.azurewebsites.net"
*  issuer: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation; OU=Microsoft IT; CN=Microsoft IT TLS CA 4
*  SSL certificate verify ok.
> POST /v1/writeDoc HTTP/1.1
> Host: ad4401boxfransprint263s2plkbwxejg.azurewebsites.net
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 104
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 104 out of 104 bytes
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Length: 141
Content-Length: 141
< Content-Type: text/plain; charset=utf-8
Content-Type: text/plain; charset=utf-8
< Server: Microsoft-IIS/10.0
Server: Microsoft-IIS/10.0
< X-Powered-By: ASP.NET
X-Powered-By: ASP.NET
< Date: Thu, 28 Feb 2019 01:00:52 GMT
Date: Thu, 28 Feb 2019 01:00:52 GMT

< 
200ok, DB write successful -> , {
  "id": "0",
  "title": "Cinderella",
  "description": "childrens book",
  "author": "random author"
* Connection #0 to host ad4401boxfransprint263s2plkbwxejg.azurewebsites.net left intact
}FrancescoWard:~ wfrs06$ 
mviencek commented 5 years ago

That works. Thank you. I noticed that the url is different from the original curl submission. you might want to update your issues and wiki

FrancescoWard commented 5 years ago

Thank you for this ! Will do.