Lab 4 not quite working - cant add data
Hi all,
I have managed to get the Roster. jar file onto PWS and it seems to be working fine. However in Lab 4 we are asked to add data to the application. I have tried the following and it is returning an error. I am trying this through a Windows Command prompt. I think the issue is to do with the PATH. I have tried all the following:
https:\\roster-beauish-gesticulator.cfapps.io OR
roster-beauish-gesticulator.cfapps.io
roster
C:\Users\PG\CF>cf app roster
Showing health and status for app roster in org xxxxx / space development as xxxxxxxxxxxxx
OK
requested state: started
instances: 1/1
usage: 1G x 1 instances
urls: roster-beauish-gesticulator.cfapps.io
last uploaded: Tue Jun 13 10:50:14 UTC 2017
stack: cflinuxfs2
buildpack: container-certificate-trust-store=2.0.0_RELEASE java-buildpack=v3.15-offline-https://github.com/cloudfoundry/java-buildpack.git#a3a9e61 java-main open-jdk-like-jre=1.8.0_121 open-jdk-like-memory-calculator=2.0.2_RELEASE spring-auto-reconfiguration=1.10...
state since cpu memory disk details
#0 running 2017-06-13 11:51:37 AM 0.5% 567.2M of 1G 154.7M of 1G
C:\Users\PG\CF>cf curl "roster-beauish-gesticulator" -H "Content-Type: application/json" -X POST -d "{"firstName":"foo", "lastName": "bar"}"
{
"description": "Unknown request",
"error_code": "CF-NotFound",
"code": 10000
}
Comments
-
Try this:
curl -H "Content-Type: application/json" -X POST -d '{"firstName":"foo", "lastName": "bar"}' http://roster-beauish-gesticulator.cfapps.io/people
All on the same line.
0 -
Yes Amatellini - that looks good. Using linux "curl" is correct for accessing this endpoint, not "cf curl" in this case.
0 -
Hello,
I had some problems to run the curl command properly under Windows.
This syntax should be OK:
curl -H "Content-Type: application/json" -X POST -d "{\"firstName\":\"foo\",\"lastName\":\"bar\"}" http://roster-presageful-creature.cfapps.io/people
Regards,
Anthony
0 -
Hi Anthony, the syntax is correct. It shold work on Windows, at least it worked for me. What kind of problem do you have?
I suggest you to install cygwin, so you can use linux syntax.
Andrea
0 -
Guys,
Many thanks for your suggestions so far but this still isnt workig for me. I am not sure if this is because it is a Windows prompt and this is a Linux command thing, a syntax mistake by myself or something else.
If I try:
curl -H "Content-Type: application/json" -X POST -d "{\"firstName\":\"foo\",\"lastName\":\"bar\"}" http://roster-beauish-gesticulator.cfapps.io
'curl' is not recognized as an internal or external command,
operable program or batch file.If I try:
cf curl -H "Content-Type: application/json" -X POST -d "{\"firstName\":\"foo\",\"lastName\":\"bar\"}" http://roster-beauish-gesticulator.cfapps.io
{
"description": "Unknown request",
"error_code": "CF-NotFound",
"code": 10000
}I have tried intalling cygwin but after installing cygwin and using the Developer libraries that include curl I find there is a known cygwin bug preventing Windows users from using curl. I am a bit stuck.
Should I try different syntax commands in Windows prompt, or should I install Linux?
0 -
Sorry, one more that I might add. If I try ' cf curl' then it seem to work and I get the following:
cf curl
Incorrect Usage: the required argument `PATH` was not providedNAME:
curl - Executes a request to the targeted API endpointUSAGE:
cf curl PATH [-iv] [-X METHOD] [-H HEADER] [-d DATA] [--output FILE]By default 'cf curl' will perform a GET to the specified PATH. If data
is provided via -d, a POST will be performed instead, and the Content-Type
will be set to application/json. You may override headers with -H and the
request method with -X.For API documentation, please visit http://apidocs.cloudfoundry.org.
EXAMPLES:
cf curl "/v2/apps" -X GET -H "Content-Type: application/x-www-form-urlencoded" -d 'q=name:myapp'
cf curl "/v2/apps" -d @/path/to/file......more stufff that I copy from the Windows promp
0 -
Hi, cf curl is only for query cf api.
You need to install curl for windows, or cygwin (I assure you that it works), or git bash (that works to).
For windows you can download curl at this link:
https://bintray.com/artifact/download/vszakats/generic/curl-7.54.1-win64-mingw.7z (source https://curl.haxx.se/download.html)
you can extract it with winrar or 7zip. You need only the bin folder.
Then open a Windows command prompt and write something like:
curl -H "Content-Type: application/json" -X POST -d "{\"firstName\":\"foo\",\"lastName\":\"bar\"}" http://roster-presageful-creature.cfapps.io/people
If you use cygwin/git bash open the bash terminial and write something like:
curl -H "Content-Type: application/json" -X POST -d '{"firstName":"foo", "lastName": "bar"}' http://roster-beauish-gesticulator.cfapps.io/people
0 -
Hello there.
I'm having similar issue and I'm not able to create data.- App was properly deployed
- I'm using an SAP Cloud Foundry instance
- I'm trying with POSTMAN (not using CURL - I'm on a Windows machine)
- When doing the POST and GET I always get status "200 OK". So this confirms app is reachable and up-and-running
- But no data seems to be stored
Here's 2 screenshots from POSTMAN.
This one with the POST requestAnd this one with the GET
What could be wrong ?
I've also looked into the logs on the instance and found nothing suspicious...
Running out of ideas....
0 -
Everything certainly looks correct. Would you be comfortable adding me to your space? I would be happy to take a look and you could remove me immediately after. If you are not comfortable with it, that is ok too.
If you are ok with adding me, you can do the following:
cf set-space-role sgreenberg@rscale.io YOUR_ORG YOUR_SPACE SpaceDeveloper
To remove me after debugging, it would be:
cf unset-space-role sgreenberg@rscale.io YOUR_ORG YOUR_SPACE SpaceDeveloper
0 -
Hi Steve @spgreenberg
Thank you for your reply.
I have now added you to my space with role Space Dev.Here's the info regarding the deployed app
URL: http://roster-shiny-klipspringer.cfapps.eu10.hana.ondemand.com
api endpoint: https://api.cf.eu10.hana.ondemand.com
api version: 2.158.0
org: bdccdb05trial
space: devThanks in advance...
0 -
Thanks for adding me. This is an interesting one, but it appears posting to https:// works while http:// fails. This is specific to this instance (SAP) and I am still trying to figure out why. I will add more shortly.
0 -
Thanks again Steve... I did saw some "foo" "bar" there... and I thought I was having some visions or going crazy...
But now I understand you were experimenting while I was trying stuff at the same time. Sorry for that.
I won't touch it for the next hours... so it's all yours.I was just doing some scale and log exercises while moving forward with this training... but I'll pause now.
0 -
But you're right... just did a quick POST using https instead, as you suggested, and it seems to be saving the data now.
You'll see some entries with my name in there "Ricardo Quintas"0 -
SAP... it's a whole new experience. Everyday there's a surprise...
0 -
I think the confusing part is caused by Postman's behavior and not entirely SAP. Though SAP could handle this better. I expand below. Feel free to remove me from your space using the
unset-space-role
command above.I will expand on what I am seeing below, but you can feel free to ignore this. It is not a Cloud Foundry issue, but standard HTTP protocols and response codes. Fair warning, it is a bit down in the weeds.
It is common for a platform like SAP to require https. This is typically handled with an HTTP status code of 301 indicating a permanent redirect when the client originally executes a GET request. However, when a client executes a POST, they could respond with a 308. This is a relatively new status code (2014) and is not a requirement. SAP does not appear to use a 308.
curl -i -H "Content-Type: application/json" -X POST -d '{"firstName":"foo","lastName": "bar"}' http://roster.../people HTTP/1.1 301 Moved Permanently Content-length: 0 Location: https://roster-.../people Connection: close
Now the tricky part... Source: https://everything.curl.dev/http/redirects
"All three of these response codes, 301 and 302/303, will assume that the client sends a GET to get the new URI, even if the client might have sent a POST in the first request."
Therefore, you are seeing Postman follow the redirect and perform a GET to the https endpoint (rather than a POST). This explains why you see the results and a 200 status code. This also explains why you don't see any errors in the logs. There are none.
Postman and the command line
curl
behave differently. Withcurl
, you explicitly see the redirect (unless you tell it to follow redirects with the-L
flag). With Postman, you do not. I suspect if SAP returned a 308, Postman would still follow the redirect but instead do the POST. There is no way to test this though as SAP does not return a 308.0 -
Thank you Steve!!
Really awesome reply.I also tried to play with POSTMAN settings, it seems there's an option to enable/disable "follow redirect"
But not much help... the only difference is that I get "1" this time, as the reply.
So using HTTPS solves the issue.
Thanks again Steve!!
0
Categories
- All Categories
- 217 LFX Mentorship
- 217 LFX Mentorship: Linux Kernel
- 788 Linux Foundation IT Professional Programs
- 352 Cloud Engineer IT Professional Program
- 177 Advanced Cloud Engineer IT Professional Program
- 82 DevOps Engineer IT Professional Program
- 146 Cloud Native Developer IT Professional Program
- 137 Express Training Courses
- 137 Express Courses - Discussion Forum
- 6.1K Training Courses
- 46 LFC110 Class Forum - Discontinued
- 70 LFC131 Class Forum
- 42 LFD102 Class Forum
- 226 LFD103 Class Forum
- 18 LFD110 Class Forum
- 36 LFD121 Class Forum
- 18 LFD133 Class Forum
- 7 LFD134 Class Forum
- 18 LFD137 Class Forum
- 71 LFD201 Class Forum
- 4 LFD210 Class Forum
- 5 LFD210-CN Class Forum
- 2 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum - Discontinued
- 2 LFD233 Class Forum
- 4 LFD237 Class Forum
- 24 LFD254 Class Forum
- 693 LFD259 Class Forum
- 111 LFD272 Class Forum
- 4 LFD272-JP クラス フォーラム
- 12 LFD273 Class Forum
- 144 LFS101 Class Forum
- 1 LFS111 Class Forum
- 3 LFS112 Class Forum
- 2 LFS116 Class Forum
- 4 LFS118 Class Forum
- 4 LFS142 Class Forum
- 5 LFS144 Class Forum
- 4 LFS145 Class Forum
- 2 LFS146 Class Forum
- 3 LFS147 Class Forum
- 1 LFS148 Class Forum
- 15 LFS151 Class Forum
- 2 LFS157 Class Forum
- 25 LFS158 Class Forum
- 7 LFS162 Class Forum
- 2 LFS166 Class Forum
- 4 LFS167 Class Forum
- 3 LFS170 Class Forum
- 2 LFS171 Class Forum
- 3 LFS178 Class Forum
- 3 LFS180 Class Forum
- 2 LFS182 Class Forum
- 5 LFS183 Class Forum
- 31 LFS200 Class Forum
- 737 LFS201 Class Forum - Discontinued
- 3 LFS201-JP クラス フォーラム
- 18 LFS203 Class Forum
- 130 LFS207 Class Forum
- 2 LFS207-DE-Klassenforum
- 1 LFS207-JP クラス フォーラム
- 302 LFS211 Class Forum
- 56 LFS216 Class Forum
- 52 LFS241 Class Forum
- 48 LFS242 Class Forum
- 38 LFS243 Class Forum
- 15 LFS244 Class Forum
- 2 LFS245 Class Forum
- LFS246 Class Forum
- 48 LFS250 Class Forum
- 2 LFS250-JP クラス フォーラム
- 1 LFS251 Class Forum
- 150 LFS253 Class Forum
- 1 LFS254 Class Forum
- 1 LFS255 Class Forum
- 7 LFS256 Class Forum
- 1 LFS257 Class Forum
- 1.2K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 118 LFS260 Class Forum
- 159 LFS261 Class Forum
- 42 LFS262 Class Forum
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 24 LFS267 Class Forum
- 22 LFS268 Class Forum
- 30 LFS269 Class Forum
- LFS270 Class Forum
- 202 LFS272 Class Forum
- 2 LFS272-JP クラス フォーラム
- 1 LFS274 Class Forum
- 4 LFS281 Class Forum
- 9 LFW111 Class Forum
- 259 LFW211 Class Forum
- 181 LFW212 Class Forum
- 13 SKF100 Class Forum
- 1 SKF200 Class Forum
- 1 SKF201 Class Forum
- 795 Hardware
- 199 Drivers
- 68 I/O Devices
- 37 Monitors
- 102 Multimedia
- 174 Networking
- 91 Printers & Scanners
- 85 Storage
- 758 Linux Distributions
- 82 Debian
- 67 Fedora
- 17 Linux Mint
- 13 Mageia
- 23 openSUSE
- 148 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 353 Ubuntu
- 468 Linux System Administration
- 39 Cloud Computing
- 71 Command Line/Scripting
- Github systems admin projects
- 93 Linux Security
- 78 Network Management
- 102 System Management
- 47 Web Management
- 63 Mobile Computing
- 18 Android
- 33 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 370 Off Topic
- 114 Introductions
- 173 Small Talk
- 22 Study Material
- 805 Programming and Development
- 303 Kernel Development
- 484 Software Development
- 1.8K Software
- 261 Applications
- 183 Command Line
- 3 Compiling/Installing
- 987 Games
- 317 Installation
- 96 All In Program
- 96 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)