Cannot update password in WSO2 with a request - rest

I'm trying to make a HTTP request to modify password from users that are stored into WSO2. I'm using the following request:
{
method: 'PUT',
url: domain + '/wso2/scim/Users/' + userId,
rejectUnauthorized: false,
headers: {
Authorization: 'Bearer ' + scimToken,
'Content-Type': 'application/json'
},
json: true,
body: {
userName : 'foo',
password : 'newPassw0rd'
}
}
But response returns a Java exception (I don't attach it here, because is too long and I think that doesn't have sense. Is related with Apache CXF).
I'm so new with SCIM and WSO2, so I think that I'm making a mistake in the request. Does anyone knows what's wrong?
Thanks!

create user with this request:
curl -v -k --user admin:admin --data '{"schemas":[],"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":"hasinitg","password":"hasinitg","emails":[{"primary":true,"value":"hasini_home.com","type":"home"},{"value":"hasini_work.com","type":"work"}]}' --header "Content-Type:application/json" https://localhost:9443/wso2/scim/Users
update password
curl -v -k --user admin:admin -X PUT -d '{"schemas":[],"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":"hasinitg", "password":"pwd123","emails":[{"value":"hasini#wso2.com","type":"work"},{"value":"hasi7786#gmail.com","type":"home"}]}' --header "Content-Type:application/json" https://localhost:9443/wso2/scim/Users/0032fd29-55a9-4fb9-be82-b1c97c073f02

Related

How do I do an graphql axios call to supabase to

I try to do an axios call to graphql in the documentation i see:
curl -X POST https://<PROJECT_REF>.supabase.co/graphql/v1 \
-H 'apiKey: <API_KEY>'\
-H 'Content-Type: application/json' \
--data-raw '
{
"query":"{ accountCollection(first: 3) { edges { node { id } } } }"
}'
I am transforming that to a axios call like that:
var callObject = {
url:https://<PROJECT_REF>.supabase.co/graphql/v1,
method:"POST",
headers:{
"Authorization" : "Bearer " + apiKey,
"apikey": apiKey,
"Content-Type": "application/json"
}
}
var response = await axios(callObject)
Now I tried many things to add the --data-raw payload into the call. But i couldn't find the solution. It always shows me a 404
How can handle that?

How can I create a pull request with github api?

The API is : /repos/{owner}/{repo}/pulls.
I used the correct token, and the request body is :
data = {
"base": "master",
"head": "owner:master",
"title": "title",
}
The head is like this:
{'Accept': 'application/vnd.github.v3+json', "Authorization": "token {}".format(git_token)}
Then I call the pull API. Returned 200.
<Response [200]>
Why? Maybe the request body wrong?
The Pull Request API specified the answer:
Status: 201 Created
Try and anddapt their example to your repository, to see if it does work:
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/pulls \
-d '{"head":"head","base":"base"}'

How I can start a build using Rest API

I want start app's build using Openshift Rest API https://docs.openshift.com/container-platform/3.7/rest_api/index.html.
What I need:
change source ref (branch) for build
start new build from new branch
without using triggers build or oc tool.
I cann't find how to do that in https://docs.openshift.com/container-platform/3.7/rest_api/apis-build.openshift.io/v1.Build.html
It can be done using OC Tool Analogue:
oc start-build name -n namespase
But I want do this using REST API
Thank you very much!
curl -H "Authorization: Bearer xxx" -H 'Accept: application/json' -XPOST "$openshiftUrl/apis/build.openshift.io/v1/namespaces/YOURNAMESPACE/buildconfigs/CONFIGNAME/instantiatebinary?name=XXXX&namespace=YOURNAMESSPACE" --data-binary #/tmp/eQXEUXr.zip
using axios
return axios({
method: 'post',
url: 'url/apis/build.openshift.io/v1/namespaces/YYY/buildconfigs/XXX/instantiatebinary?name=XXX&namespace=YYY',
data: fs.createReadStream('/tmp/eQXEUXr.zip'),
headers: {
'content-type': `application/octet-stream`,
'Authorization': 'Bearer aaaaaa',
'Accept': 'application/json'
},
maxContentLength: Infinity,
maxBodyLength: Infinity,
httpsAgent: new Agent({
rejectUnauthorized: false
}),
timeout: 300000,
}

Salesforce Bulk Job CSV Upload via Google Apps Script UrlFetchApp

I'm attempting to use Google Apps Script to access Salesforce's Bulk API 2.0 and upload the CSV data to a job, however Salesfore is returning
[{"errorCode":"METHOD_NOT_ALLOWED","message":"HTTP Method 'GET' not allowed. Allowed are PUT"}]
Given my experience with the Salesforce API, I highly doubt the issue is actually with the method type, but that there is some other validation which is causing this error. However, upon inspection of the request body and comparing it to what I successfully submit through cURL, I don't see what I can do to resolve.
The request code:
var headers = {
"Authorization": "Bearer TOKEN"
};
var options = {
"method": "put",
"contentType": "text/csv",
"headers": headers,
"payload": "Id,Entity_Name__c\n001,One\n002,Two\n003,Three"
};
var url = INSTANCE + "/services/data/v44.0/jobs/ingest/" + JOB_ID + "/batches";
UrlFetchApp.fetch(url, options);
Google Apps Script request as returned via getRequest():
{
"headers": {
"Authorization": "Bearer TOKEN"
},
"method": "put",
"payload": "Id,Entity_Name__c\n001,One\n002,Two\n003,Three",
"followRedirects": true,
"validateHttpsCertificates": true,
"useIntranet": false,
"contentType": "text/csv",
"url": "INSTANCE/services/data/v44.0/jobs/ingest/JOB_ID/batches"
}
cURL request:
curl --request PUT \
--url INSTANCE/services/data/v44.0/jobs/ingest/JOB_ID/batches \
--header 'authorization: Bearer TOKEN' \
--header 'content-type: text/csv' \
--data '"Id,Entity_Name__c\n001,One\n002,Two\n003,Three"'
How can I resolve this?

Convert cURL to Postman REST Call

How can I convert the following cURL command to a Postman rest call?
curl -X POST abc.com/input.import
-H 'content-type: application/x-www-form-urlencoded'
--data-urlencode "apiKey=123-456"
--data-urlencode "secret=12/her"
--data-urlencode "userKey=ApUR"
--data-urlencode "email=fakeImportedAccount#example.com"
--data-urlencode "profile={'firstName':'John','lastName':'Kira'}"
I tried the following:
URL: (POST) abc.com/input.import
Header: Content-Type:application/json
Body:
{
"apiKey":"123-456",
"userKey":"ApUR",
"secret":"12/her",
"email":"fakeImportedAccount#example.com",
"profile": {
"firstName":"John",
"lastName":"Kira"
}
}
EDIT: Raw-body format in Postman is required. Import creates the request in "x-www-form-urlencoded" form
The content-type is not application/json, it's application/x-www-form-urlencoded. What you need to do is in the body tab, select application/x-www-form-urlencoded. The content-type header will automatically be set for you. The just start adding the key/value pairs (the --data-urlencoded arguments)
UPDATE
Unrelated, but for those looking for a way to post JSON (which is very common), you would use the "raw" radio button and then you would manually type in the JSON to the window they provide. Also you would set the Content-Type header to application/json.
I finally found: I have to url-encode every key value and send it with Content-Type:application/x-www-form-urlencoded.
Header:application/x-www-form-urlencoded
Body:
{
"apiKey":"123-456",
"userKey":"ApUR",
"secret":"12%2Fher",
"email":"fakeImportedAccount%40example.com",
"profile":{
"firstName":"John",
"lastName":"Kira"
}
}