I want to add new targetserver but I am getting following error.
curl: (6) Could not resolve host: <TargetServer name=TS1><Host>test.jokeindex.co
m<
curl: (6) Could not resolve host: \
{
"fault": {
"faultstring": "XMLThreatProtection stepDefinition XMLThreat: Execution
failed. reason: Unexpected char while looking for open tag ('<') character",
"detail": {
"errorcode": "steps.xmlthreatprotection.ExecutionFailed"
}
}
}
curl command:
curl -H "Content-Type:text/xml" -X POST -d \ "<TargetServer name="TS1"><Host>test.jokeindex.com</Host><Port>80</Port><IsEnabled>true</IsEnabled></TargetServer>" \ -u nisarg:mypwd https://api.enterprise.apigee.com/v1/o/nisarg/environments/test/targetservers
You need to use single quotes around the data, since you are using double quotes within.
So try this instead:
curl -H "Content-Type:text/xml" -X POST -d '<TargetServer name="TS1"><Host>test.jokeindex.com</Host><Port>80</Port><IsEnabled>true</IsEnabled></TargetServer>' -u nisarg:mypwd https://api.enterprise.apigee.com/v1/o/nisarg/environments/test/targetservers
Related
curl -X POST http://textbelt.com/text \
--data-urlencode phone=' xx xxxxxxxxxx' \
--data urlencode message='hello' \
-d key=textbelt
output
{"success":false,"error":"Missing message parameter. Your request may be malformed."}curl: (6) Could not resolve host: message=hello
I am trying to write a script to move repos in a project to another project but I am getting a 400 error whenever I try.
My python requests line looks like:
url = 'https://bitbucketserver.com/rest/api/1.0/projects/example1/repos/repo1'
token = 'TokenString'
response = requests.put(url, headers={'Content-Type': 'application/json', 'Authorization': 'Bearer' + token}, data={'project': {'key': 'NEW_PROJECT'}}, verify=False)
I get a response 400 that says 'Unexpected character ('p' (code112)): expected a valid value (number, string, array, object, true, false, or null) at [Source: com.atlassian.stash.internal.web.util.web.CountingServletInputStream#7ccd7631; line 1, column 2]
I'm not sure where my syntax is wrong
Not python, but work for me via curl:
curl -u 'USER:PASSWORD' --request PUT \
--url 'https://stash.vsegda.da/rest/api/1.0/projects/OLD_PROJECT/repos/REPO_TO_MOVE' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"project": {"key":"NEW_PROJECT"}
}'
Maybe can someone help.
I'm getting an error using amazon advertising API. I'm currently trying to request performance report using https://advertising-api.amazon.com/v1/campaigns/report.
But the server reply Cannot consume content type
here is my request header and body.
End point : https://advertising-api.amazon.com/v1/campaigns/report
Method Type: POST
Header :
{
Authorization: 'Bearer xxxxxx',
Amazon-Advertising-API-Scope: '11111111111',
Content-Type: 'application/json'
}
Body :
{
campaignType:'sponsoredProducts',
reportDate:'20180320',
metrics:'impressions,clicks'
}
I think I did everything correctly as API document but it says
{
"code": "415",
"details": "Cannot consume content type"
}
Please help me.
Try this way
curl -X POST \
https://advertising-api.amazon.com/v1/campaigns/report \
-H 'Amazon-Advertising-API-Scope: REPLACE_YOUR_PROFILE_ID' \
-H 'Authorization: REPLACE_YOUR_ACCESS_TOKEN' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'Host: advertising-api.amazon.com' \
-H 'cache-control: no-cache' \
-d '{
"campaignType": "sponsoredProducts",
"metrics": "impressions,clicks",
"reportDate": "20181101"
}
And you will get a response like
{
"reportId": "amzn1.clicksAPI.v1.p1.......",
"recordType": "campaign",
"status": "IN_PROGRESS",
"statusDetails": "Report is being generated."
}
You can put this curl command in Postman also.
I think your Body may be missing a parameter. When I successfully make a similar POST I need my body to have at least what you have written as well as the segment type. Try adding this to your body:
{
campaignType:'sponsoredProducts',
reportDate:'20180320',
metrics:'impressions,clicks'
segment:'query'
}
Just copy the body from the documentation and paste it in the raw area (of postman) and choose JSON format. For me it works fine.
I'm trying to find all projects created between the times 1493872000 and 1493872435 on Artifactory, but I'm getting 405.
$ curl -X POST -H "X-JFrog-Art-Api: <KEY>" "http://localhost:8081/artifactory/api/search/creation?from=1493872000&to=1493872435&repos=project1"
{
"errors" : [ {
"status" : 405,
"message" : "Method Not Allowed"
} ]
}
Is there something wrong with my command? I'm using the documentation here.
Not all the API calls seem to work for me, but curl -H "X-JFrog-Art-Api: <KEY>" -X PUT "http://localhost:8081/artifactory/project1/artifacts.zip" -T artifacts.zip (to upload an artifact) does.
Use GET, not POST:
curl -X GET -H "X-JFrog-Art-Api: <KEY>" "http://localhost:8081/artifactory/api/search/creation?from=1493872000&to=1493872435&repos=project1"
I would like to get some information from jira project, using http method, f.e.:
curl -D- -u uname:pass -X PUT -d "Content-Type: application/json" http://localhost:8080/jira/rest/api/2/search?jql=project=XXX%20created='-5d'
After all, I received a lot of information, but I would like get only one tag:
{"expand":"schema,names","startAt":0,"maxResults":50,"total":1234,"issues":
here - multiple lines....
Have You maybe idea, how I can get only "total":1234 field?
Thank You in advance.
Add the following to your URL:
&maxResults=0
Which will result in a return like:
{
"startAt": 0,
"maxResults": 0,
"total": 3504,
"issues": []
}
You can then pipe you're curl to an awk and get the number only with:
curl --silent "https://jira.atlassian.com/rest/api/2/search?jql=project=STASH%20&created=%27-5d%27&maxResults=0" | awk '{split($0,a,":"); print a[4]}' | awk '{split($0,a,","); print a[1]}'