I have wso2am-2.5.0 and apimcli-1.1.0
all downloaded from here: https://wso2.com/api-management/install/
i try to configure and use apimcli with wso2am running locally
so, i've added the environment named local:
apimcli add-env -n local
--apim https://localhost:9443
--registration https://localhost:9443/identity/connect/register
--import-export https://localhost:9443/api-import-export-2.2.0-v2
--api_list https://localhost:9443/api/am/publisher/v0.12/apis
--token https://localhost:9443/oauth2/token
note the parameter --api_list defined in documentation as --list
but apimcli add-env --help displays --api_list instead
and finally I try to get list of apis:
apimcli list apis -e local -u admin -p admin --insecure --verbose
but it gives me the following output:
Executed ImportExportCLI (apimcli) on Wed, 26 Sep 2018 15:59:48 EEST
[INFO]: Insecure: true
[INFO]: apis called
[INFO]: Environment: 'local'
[INFO]: Reg Endpoint read: https://localhost:9443/identity/connect/register
Getting ClientID, ClientSecret: Status - 403 Forbidden
Error: <nil>
Body:
<html>
<head>
<title>Error 403</title>
</head>
<body>
<h1>Error 403 - Forbidden</h1>
</body>
</html>
Error: Request didn't respond 200 OK: 403 Forbidden
[INFO]: EnvKeysAll: &{map[]}
[ERROR]: connecting to https://localhost:9443/oauth2/token
apimcli: Unable to connect. Reason: Status: 400 Bad Request
[ERROR]: Unable to connect.: Status: 400 Bad Request
Exit status 1
It seems the publisher API version is wrong.
--api_list https://localhost:9443/api/am/publisher/v0.12/apis
Make it v0.13 and try again.
Edit: It seems the DCR endpoint is also wrong. Change it like this.
--registration https://localhost:9443/client-registration/v0.13/register
It seems the readme file shipped with the cli is not correct. :-/
Please use the following doc instead.
https://docs.wso2.com/display/AM250/Migrating+the+APIs+and+Applications+to+a+Different+Environment
Related
I'm using google cloud's "Hello World" demo for cloud functions but the URL it produces gives me an error:
Error: Page not found
The requested URL was not found on this server.
I follow the tutorial, check allow unauthenticated, etc yet the url trigger leads me to the error.
The curl response requested also returns an error:
curl -X POST MY_URL -H "Content-Type:application/json" -d '{"name":"Jane"}'
returns:
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>404 Page not found</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Page not found</h1>
<h2>The requested URL was not found on this server.</h2>
<h2></h2>
</body></html>
Any ideas why?
edit: testing works just fine
Edit2: the url in MY_URL is structured like this:
curl -X POST https://us-west1-PROJECT-NAME.cloudfunctions.net/FUNCTION-NAME -H "Content-Type:application/json" -d '{"message":"Jane"}'
According to this GCP doc:
As of January 15, 2020, all HTTP functions by default require most invokers to be authenticated. To allow unauthenticated invocation you must specify this at or after deployment.
After deployment, manually add the Cloud Functions Invoker permission to allUsers users in the Cloud Functions page in the Google Cloud Console.
However, it's always a best practice to set authorization on your cloud functions.
I was able to curl the endpoint successfully using:
curl -X POST https://us-central1-<project_name>.cloudfunctions.net/<function_name> -H "Authorization:
bearer $(gcloud auth print-identity-token)" -H "Content-Type:application/json" -d '{"name": "Jane"}'
Output:
I'm trying to Execute the AWS step function from API Gateway, It's working as expected.
Whenever I'm passing the input, statemachinearn(stepfunction name to execute) It's triggering the step function.
But It's still returning the status code 200, whenever it's not able to find the stepfunction, I want to return the status code 404 if the apigateway not found that stepfunction.
Could you please help me on that
Response:
Status: 200ok
Expected:
Status: 404
Thanks,
Harika.
As per the documentation StartExecution API call do return 400 Bad Request for non existent statemachine which is correct as RESTful API standard.
StateMachineDoesNotExist
The specified state machine does not exist.
HTTP Status Code: 400
From the RESTful API point of view, endpoint /execution/(which I created in API Gateway for the integration setup) is a resource, no matter it accepts GET or POST or something else. 404 is only appropriate when the resource /execution/ itself does not exist. If /execution/ endpoint exists, but its invocation failed (no matter what the reasons), the response status code must be something other than 404.
So in the case of the returned response(200) for POST call with non-existent statemachine it is correct. But when API Gateway tried to make the call to non-existent statemachine it got 404 from StartExecution api call which it eventually wrapped into a proper message instead of returning 404 http response.
curl -s -X POST -d '{"input": "{}","name": "MyExecution17","stateMachineArn": "arn:aws:states:eu-central-1:1234567890:stateMachine:mystatemachine"}' https://123456asdasdas.execute-api.eu-central-1.amazonaws.com/v1/execution|jq .
{
"__type": "com.amazonaws.swf.service.v2.model#StateMachineDoesNotExist",
"message": "State Machine Does Not Exist: 'arn:aws:states:eu-central-1:1234567890:stateMachine:mystatemachine1'"
}
Let's say you create another MethodResponse where you can provide an exact HTTP Status Code in your case 404 which you want to return and you do an Integration Response where you have to choose the Method Response by providing either Exact HTTP Responce Code(400 -> Upstream response from the **StartExecution** API Call) OR a Regex -> (4\{d}2) matching all the 4xx errors.
In that case you will be giving 404 for all the responses where the upstream error 4xx StartExecution Errors
ExecutionAlreadyExists -> 400
ExecutionLimitExceeded -> 400
InvalidArn -> 400
InvalidExecutionInput -> 400
InvalidName -> 400
StateMachineDeleting -> 400
StateMachineDoesNotExist -> 400
Non Existent State Machine:
curl -s -X POST -d '{"input": "{}","name": "MyExecution17","stateMachineArn": "arn:aws:states:eu-central-1:1234567890:stateMachine:mystatemachine1"}' https://123456asdasdas.execute-api.eu-central-1.amazonaws.com/v1/execution|jq .
< HTTP/2 404
< date: Sat, 30 Jan 2021 14:12:16 GMT
< content-type: application/json
...
{
"__type": "com.amazonaws.swf.service.v2.model#StateMachineDoesNotExist",
"message": "State Machine Does Not Exist: 'arn:aws:states:eu-central-1:1234567890:stateMachine:mystatemachine1'"
}
Execution Already Exists
curl -s -X POST -d '{"input": "{}","name": "MyExecution17","stateMachineArn": "arn:aws:states:eu-central-1:1234567890:stateMachine:mystatemachine"}' https://123456asdasdas.execute-api.eu-central-1.amazonaws.com/v1/execution|jq .
* We are completely uploaded and fine
< HTTP/2 404
< date: Sat, 30 Jan 2021 14:28:27 GMT
< content-type: application/json
{
"__type": "com.amazonaws.swf.service.v2.model#ExecutionAlreadyExists",
"message": "Execution Already Exists: 'arn:aws:states:eu-central-1:1234567890:execution:mystatemachine:MyExecution17'"
}
Which I think will be misleading.
I have an gitlab ci yaml file. and 2 jobs. My .gitlab-ci.yaml file is:
variables:
MSBUILD_PATH: 'C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe'
SOLUTION_PATH: 'Source/NewProject.sln'
stages:
- build
- trigger_IT_service
build_job:
stage: build
script:
- '& "$env:MSBUILD_PATH" "$env:SOLUTION_PATH" /nologo /t:Rebuild /p:Configuration=Debug'
trigger_IT_service_job:
stage: trigger_IT_service
script:
- 'curl http://webapps.xxx.com.tr/dataBus/runTransfer/ctDigiTransfer'
And It's my trigger_IT_service job report:
Running on DIGITALIZATION...
00:00
Fetching changes with git depth set to 50...
00:05
Reinitialized existing Git repository in D:/GitLab-Runner/builds/c11pExsu/0/personalname/newproject/.git/
Checking out 24be087a as master...
Removing Output/
git-lfs/2.5.2 (GitHub; windows amd64; go 1.10.3; git 8e3c5c93)
Skipping Git submodules setup
$ curl http://webapps.xxx.com.tr/dataBus/runTransfer/ctDigiTransfer
00:02
StatusCode : 200
StatusDescription : 200
Content : {"status":200,"message":"SAP transfer started. Please
check in db","errorCode":0,"timestamp":"2020-03-25T13:53:05
.722+0300","responseObject":null}
RawContent : HTTP/1.1 200 200
Keep-Alive: timeout=10
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/json;charset=UTF-8
Date: Wed, 25 Mar 2020 10:53:05 GMT
Server: Apache
I have to control the this report "Content" part in gitlab ci yaml
If "message" is "SAP transfer started. Please check in db" the pipeline should pass otherwise must be failed.
Actually my question is:
how to parse Http json response and fail or pass job based on that
Thank you for all your helps.
Best way would be to install some tool to parse json and use it, different examples here
Given json example from comment:
{
"status": 200,
"message": "SAP transfer started. Please check in db",
"errorCode": 0,
"timestamp": "2020-03-25T17:06:43.430+0300",
"responseObject": null
}
If you can install python3 on your runner you could achieve it all with script:
import requests; # note this might require additional install with pip install requests
message = requests.get('http://webapps.xxx.com.tr/dataBus/runTransfer/ctDigiTransfer').json()['message']
if message != 'SAP transfer started. Please check in db':
print('Invalid message: ' + message)
exit(1)
else:
print('Message ok')
So trigger_IT_service stage in your yaml would be:
trigger_IT_service_job:
stage: trigger_IT_service
script: >
python -c "import requests; message = requests.get('http://webapps.xxx.com.tr/dataBus/runTransfer/ctDigiTransfer').json()['message']; (print('Invalid message: ' + message), exit(1)) if message != 'SAP transfer started. Please check in db' else (print('Message ok'), exit(0))"
I am trying to delete a file (video) from Google Cloud Storage via the cloudstorage api but although the file exists I'm getting the following error:
cloudstorage.delete('/catchamove-video/products/6411421952770048.mp4')
*** NotFoundError: Expect status [204] from Google Storage. But got status 404.
Path: '/catchamove-video/products/6411421952770048.mp4'.
Request headers: None.
Response headers: {'transfer-encoding': 'chunked', 'date': 'Sun, 07 May 2017 12:31:47 GMT', 'server': 'Development/2.0'}.
Body: ''.
Extra info: None.
Both the bucket and file are present on the console.
I am facing the same problem: getting 404 when delete a folder via REST API.
After some tests, I figured out how delete folder of GCP storage -
Have to delete all files (objects) in the folder, files in sub-folders and sub-folders and folder. Be noticed that when deleting empty folder, you may still get "404 Not Found"(normally gets 204), just ignore it and the empty folder will be actually deleted.
Examples:
curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2Fsub-folder%2Ffile1
curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2Fsub-folder%2Ffile2
curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2Fsub-folder%2F #May get 204 or 404 response code
curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2F #May get 204 or 404 response code
NOTE: "%2F" in the URL is actually "/" character
I'm trying to use mailgun in my Django project hosted on Pythonanywhere.
In my WSGI file, I have:
os.environ['DJANGO_MAILGUN_SERVER_NAME'] = 'https://api.mailgun.net/v3/sandboxnumbersomething.mailgun.org/messages'
os.environ['DJANGO_MAILGUN_API_KEY'] ='mykey'
and my settings are:
# EMAIL
# ------------------------------------------------------------------------------
DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL',
default='Apitrak <noreply#apitrak.com>')
EMAIL_BACKEND = 'django_mailgun.MailgunBackend'
MAILGUN_ACCESS_KEY = env('DJANGO_MAILGUN_API_KEY')
MAILGUN_SERVER_NAME = env('DJANGO_MAILGUN_SERVER_NAME')
When my app fire an email (for example at signup), I have a 404 error:
MailgunAPIError at /accounts/email/
<Response [404]>
Request Method: POST
Request URL: https://vincentle.pythonanywhere.com/accounts/email/
Django Version: 1.8.6
Exception Type: MailgunAPIError
Exception Value:
<Response [404]>
Exception Location: /home/vincentle/.virtualenvs/apitrak/lib/python3.4/site-packages/django_mailgun.py in _send, line 154
Python Executable: /usr/local/bin/uwsgi
Python Version: 3.4.0
Python Path:
['/var/www',
'.',
'',
'/var/www',
'/home/vincentle/.virtualenvs/apitrak/lib/python3.4',
'/home/vincentle/.virtualenvs/apitrak/lib/python3.4/plat-x86_64-linux-gnu',
'/home/vincentle/.virtualenvs/apitrak/lib/python3.4/lib-dynload',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/home/vincentle/.virtualenvs/apitrak/lib/python3.4/site-packages',
'/home/vincentle/apitrak']
Server time: Tue, 17 Nov 2015 16:02:28 +0100
I've tried a curl in the virtualenv of my WebApp:
curl -s --user 'api:key-NUMBERS' https://api.mailgun.net/v3/NUMBERS.mailgun.org/messages -F from='Excited User <excited#samples.mailgun.org>' -F to='vincent#vincentle.fr' -F subject='Hello' -F text='Testing some Mailgun awesomeness!'
And this works OK.
The setting DJANGO_MAILGUN_SERVER_NAME should be a domain name, not a url.
Try the following:
os.environ['DJANGO_MAILGUN_SERVER_NAME'] = '<sandboxnumbersomething>.mailgun.org'
From the readme:
Replace SERVER-NAME with the last part of your "API Base URL" (e.g. https://api.mailgun.net/v3/<your_server_name>), also found in your Mailgun account details.