I am getting the below error when trying to query PUT command with curl :
"error":"bad_request","reason":"Missing request body"
this is the query i am trying to execute to insert a new document in the database:
curl -X PUT http://127.0.0.1:5984/mychannel_fabcar/CAR10/ '{"docs" : [ "_id": "CAR10", "colour": "white","make": "Ford", "model": "Figo","owner": "Meghna","~version": "\u0000CgMBAgA="]}'
shouldn't you also give the option -d for the body?
curl -X PUT http://127.0.0.1:5984/mychannel_fabcar/CAR10/ -d '{"docs": [ "_id": "CAR10", "colour": "white","make": "Ford", "model":"Figo","owner": "Meghna","~version": "\u0000CgMBAgA="]}'
see this thread (uploading files) and this thread (uploading raw data) for a detailed explanantion.
Related
I'm trying to use the new LinkedIn Posts API to make a post. I started by trying to duplicate the curl sample code at
https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/posts-api?view=li-lms-2022-06&tabs=curl#text-only-post-creation-sample-request
curl -X POST 'https://api.linkedin.com/rest/posts \
-H 'Authorization: Bearer {INSERT_TOKEN}' \
-H 'X-Restli-Protocol-Version: 2.0.0' \
-H 'LinkedIn-Version: {version number in the format YYYYMM}' \
-H 'Content-Type: application/json' \
--data '{
"author": "urn:li:organization:5515715",
"commentary": "Sample text Post",
"visibility": "PUBLIC",
"distribution": {
"feedDistribution": "NONE",
"targetEntities": [],
"thirdPartyDistributionChannels": []
},
"lifecycleState": "PUBLISHED",
"isReshareDisabledByAuthor": false
}'
I replaced the bearer token with my own, and changed the author to urn:li:person:{my id}
I get the following error suggesting that I a have asked for a specific adContext:
{"errorDetailType":"com.linkedin.common.error.BadRequest","code":"MISSING_REQUIRED_FIELD_FOR_DSC","message":"Field /adContext/dscAdAccount is required when the post is a Direct Sponsored Content, but missing in the request","errorDetails":{"inputErrors":[{"description":"Field /adContext/dscAdAccount is required when the post is a Direct Sponsored Content, but missing in the request","input":{"inputPath":{"fieldPath":"/adContext/dscAdAccount"}},"code":"MISSING_REQUIRED_FIELD_FOR_DSC"}]},"status":400}
In the hope that that was the default, I added an adContext "adContext": {"isDsc": False}
and that gave me {"errorDetailType":"com.linkedin.common.error.BadRequest","code":"UNPROCESSABLE_ENTITY","message":"ReadOnly field present in a create request","errorDetails":{"inputErrors":[{"description":"ReadOnly field present in a create request","input":{"inputPath":{"fieldPath":"/adContext/isDsc"}},"code":"UNPROCESSABLE_ENTITY"}]},"status":400}
I also tried a blank adContext.
Has anyone had any luck using this API, or can anyone tell me what I'm doing wrong?
I'm trying to scrape an Amazon page with browserless:
curl -X POST \
"https://chrome.browserless.io/content?token=<token>" \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d ' {
"url": "https://www.amazon.com/gp/your-account/order-details/?orderID=114-5444651-3149007",
"elements": [{
"selector": "a",
}],
"cookies": [
<many cookies>
],
}'
but I keep getting:
[{"message":"\"elements\" is not allowed","path":["elements"],"type":"object.unknown","context":{"child":"elements","label":"elements","value":[{"selector":"a","timeout":10000}],"key":"elements"}}]%
If I exclude the elements object, it works fine but returns the entire 6,000 lines of <html>.
(What I actually want is document.getElementsByClassName('shipment')[0].innerText)
When I try the examples (from the docs) they work fine.
Its because elements only available for /scrape API
You are using /content
According to https://developer.openstack.org/api-ref/container-infrastructure-management/#create-new-cluster all I would need to create the cluster is pass the parameters like:
curl --header "X-Auth-Token: blah" \
-X POST https://myopenstack:9511/v1/clusters -d name="Swarm-cluster-ansible" -d cluster_template_id="7402f9d3-4881-440f-8496-08d420935f58" -d node_count=2 -d keypair="k8s-gitlab-ci"
It is giving me:
{"errors": [{"status": 400, "code": "client", "links": [], "title": "Unknown argument: \"cluster_template_id, node_count, keypair, name\"", "detail": "Unknown argument: \"cluster_template_id, node_count, keypair, name\"", "request_id": ""}]}
If I try it this way:
curl --header "X-Auth-Token: blah" \
-X POST https://myopenstack:9511/v1/clusters -d cluster='{
"name":"swarm",
"master_count":1,
"discovery_url":null,
"cluster_template_id":"7402f9d3-4881-440f-8496-08d420935f58",
"node_count":1,
"keypair":"k8s-gitlab-ci",
"master_flavor_id":null,
"labels":{
},
"flavor_id":null
}'
{"errors": [{"status": 400, "code": "client", "links": [], "title": "Invalid input for field/attribute cluster", "detail": "Invalid input for field/attribute cluster. Value: '{\n \"name\":\"swarm\",\n \"master_count\":1,\n \"discovery_url\":null,\n \"cluster_template_id\":\"7402f9d3-4881-440f-8496-08d420935f58\",\n \"node_count\":1,\n \"keypair\":\"k8s-gitlab-ci\",\n \"master_flavor_id\":null,\n \"labels\":{\n },\n \"flavor_id\":null\n}'. unable to convert to Cluster. Error: __init__() takes exactly 1 argument (2 given)", "request_id": ""}]}
Any idea?
EDIT: I am able to do a GET and retrieve the list of existing clusters.
-H "Content-Type: application/json" is enough in this case so the body is interpreted as JSON.
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"