How can I create a pull request with github api? - github

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"}'

Related

Getting "HTTP method not allowed, supported methods: GET" when request is successful

I am working on a Akka-Http project in which I am writing a POST endpoint http://localhost:8080/api/v1/internal/admin/import which requires a header with an access token.
My curl request is as follows
curl --location --request POST 'http://localhost:8080/api/v1/internal/admin/import' \
--header 'Content-Type: application/json' \
--header 'Accept: text/plain' \
--header 'Authorization: correct-token' \
--data-raw '{
"id": 100,
"name": "test"
}'
When the access token is incorrect, I get the http response in the exact format that is expected
"status": {
"code": 403,
"error": "authorization_error",
"details": "Invalid token"
}
}
But as soon as I provide a correct token in the header, the http request is successful, but I get a weird message HTTP method not allowed, supported methods: GET.
Just before sending the correct response, I tried to print the json and its correct. My code looks as follows :
onComplete(futureR) {
case Success(result) =>
println(s"Success response json is ${Json.toJson(result)}")
complete(result)
case Failure(ex) => complete(
500 -> StatusResponse(ApiStatus(500, None, None))
)
}
The result I am getting on terminal is Success response json is {"status":{"code":0}} which is correct, however in Postman, I keep on getting the error HTTP method not allowed, supported methods: GET.
Any pointers to this problem ? TIA

How to send a form with just 1 TextBox and 1 Button via Postman

I tried creating a request via postman with below Request Body with 1 input text,
{
"subject" : "Fill Up the Form",
"content" : "Form Data",
"formMetaData" : {
"id": "myform1234",
"controls": [{
"type": "Circuit.Enums.FormControlType.INPUT",
"name": "Your Name"
}]
}
}
But I am only getting the Content and Subject part in Circuit Sandbox. Form part is missing
Using the Rest API and not the SDK you should replace the ENUMS with strings for the control types.
I have a working code sample in Postman for this
curl -X POST \
https://beta.circuit.com/rest/v2/conversations/6aecff9e-1aa0-46f3-8e24-8519e2956291/messages \
-H 'Authorization: Bearer 11111omitted' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-F 'content=Please fill in the form below' \
-F 'subject=Test form' \
-F 'formMetaData={"id":"myformonbeta","title":"Test Form","controls":[{"type":"INPUT","name":"name","text":"What is your namne ?","rows":1},{"type":"BUTTON","text":"Send"}]}'
Hope this helps

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?

Integrating MATLAB with Google BigQuery via REST API

I'm trying to use MATLAB's webread function to query Google BigQuery via the REST API, and am having issues. The following curl request is successful:
curl 'https://www.googleapis.com/bigquery/v2/projects/<MyProjectId>/queries' \
-X POST \
-H 'Authorization: Bearer <MyBearerToken>' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data-binary '{"query":"select count(1) from MyTable","useLegacySql":false}' \
--compressed
However, the following MATLAB code:
api = 'https://www.googleapis.com/bigquery/v2/';
access_token = '<MyAccessToken>';
options = weboptions('RequestMethod', 'post');
r = webread([api 'projects/<MyProjectId>/queries?access_token=' access_token], ...
'query', 'select count(1) from MyTable', ...
'useLegacySql', false, ...
options);
generates the following error:
Error using readContentFromWebService (line 45)
The server returned the status 400 with message "Bad Request" in response to the request to URL
https://www.googleapis.com/bigquery/v2/projects/<MyProjectId>/queries?access_token=<MyAccessToken>&query=select+count(1)+from+<MyTable>&useLegacySql=0
Entering the URL in the MATLAB error into a POST requester shows the following (generic) error, so it appears the URL is malformed:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter is missing"
}
],
"code": 400,
"message": "Required parameter is missing"
}
}
How can I use MATLAB's webread to accomplish the same thing as the above curl request?
It turns out that the webread function doesn't have this functionality. This issue is resolved successfully by using webwrite as follows:
options = weboptions( ...
'RequestMethod', 'post', ...
'MediaType', 'application/json');
data = struct( ...
'query', 'select count(1) from MyTable', ...
'useLegacySql', false);
r = webwrite([api 'projects/<MyProjectId>/queries?access_token=' access_token], ...
data, ...
options);

Cannot update password in WSO2 with a request

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