Ich versuche zu testen, ob meine API funktioniert. Um dies zu tun mir die folgende Codezeile ausgeführt wird:mit curl zu einem API-POST (Debug-Hilfe)
mftaff:~/workspace (api-controller) $ curl -v -H "Accept: application/json" -H "Origin: https://interstellar-wiki-mftaff.c9users.io" -H "Content-Type: application/json" -X POST -d '{"name":"foobar"}' https://blocmetrics-mftaff.c9users.io:8080/api/events |& tee -a output.txt
Allerdings, wenn ich dies laufe ich die folgende Ausgabe an die Konsole am Empfang:
* Hostname was NOT found in DNS cache
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 104.197.98.45...
* Connected to blocmetrics-mftaff.c9users.io (104.197.98.45) port 8080 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
} [data not shown]
* SSLv3, TLS handshake, Server hello (2):
{ [data not shown]
* SSLv3, TLS handshake, CERT (11):
{ [data not shown]
* SSLv3, TLS handshake, Server key exchange (12):
{ [data not shown]
* SSLv3, TLS handshake, Server finished (14):
{ [data not shown]
* SSLv3, TLS handshake, Client key exchange (16):
} [data not shown]
* SSLv3, TLS change cipher, Client hello (1):
} [data not shown]
* SSLv3, TLS handshake, Finished (20):
} [data not shown]
* SSLv3, TLS change cipher, Client hello (1):
{ [data not shown]
* SSLv3, TLS handshake, Finished (20):
{ [data not shown]
* SSL connection using ECDHE-RSA-AES256-SHA384
* Server certificate:
* subject: OU=Domain Control Validated; OU=EssentialSSL Wildcard; CN=*.c9users.io
* start date: 2016-10-17 00:00:00 GMT
* expire date: 2017-11-01 23:59:59 GMT
* subjectAltName: blocmetrics-mftaff.c9users.io matched
* issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Domain Validation Secure Server CA
* SSL certificate verify ok.
> POST /api/events HTTP/1.1
> User-Agent: curl/7.35.0
> Host: blocmetrics-mftaff.c9users.io:8080
> Accept: application/json
> Origin: https://interstellar-wiki-mftaff.c9users.io
> Content-Type: application/json
> Content-Length: 17
>
} [data not shown]
* upload completely sent off: 17 out of 17 bytes
< HTTP/1.1 401 Unauthorized
< x-xss-protection: 1; mode=block
< x-content-type-options: nosniff
< content-type: application/json; charset=utf-8
< cache-control: no-cache
< x-request-id: d62f648d-a901-4029-be1b-08aa65cc4b92
< x-runtime: 0.008397
* Server WEBrick/1.3.1 (Ruby/2.3.0/2015-12-25) is not blacklisted
< server: WEBrick/1.3.1 (Ruby/2.3.0/2015-12-25)
< date: Fri, 24 Mar 2017 08:18:39 GMT
< content-length: 61
< X-BACKEND: apps-proxy
<
21 78 0 0 100 17 0 12 0:00:01 0:00:01 --:--:-- 12{ [data not shown]
100 78 100 61 100 17 42 11 0:00:01 0:00:01 --:--:-- 42
* Connection #0 to host blocmetrics-mftaff.c9users.io left intact
{"error":"You need to sign in or sign up before continuing."}
Ich bin ganz neu in all das ... und ich weiß nicht, wie man diese Ausgabe in Bezug auf die Identifizierung von Fehlern und/oder Fehlern in den Vordergrund stellt.
Was ich bisher weiß: Es gibt eine Art von Fehler/Fehler, weil ein neues Ereignis (welches das Ziel dieses API POST ist) nicht erstellt wird. Ich bin auf der Hostwebsite und der Ursprungswebsite angemeldet, sodass die letzte Zeile über ein falsches Zeichen verwirrend ist.
Jede Hilfe, die angibt, wo der Fehler liegen könnte, wäre hervorragend!
(Wenn der Leser fühlt er sich mehr Informationen benötigt, lassen Sie einen Kommentar, und ich werde es gerne liefern!)
Wenn Sie über den Browser angemeldet sind, wird der Cookie nur in Ihrem Browser gespeichert. Die Curl ist völlig getrennt und Sie benötigen eine Art Autorisierungstoken, das in der Anfrage gesendet wird. –
'HTTP/1.1 401 Unauthorized' bedeutet fehlende HTTP-Autorisierung, siehe curl' --user' und Freunde. –