Click here to Skip to main content
15,905,913 members

Comments by AmitabhaGhosh123 (Top 10 by date)

AmitabhaGhosh123 2-Nov-20 9:30am View    
Hi Richard,

The same request is working fine in postman but not working while calling the api from code.

Below is the documentation for the update api.

POST Update Tasks
https://devza.com/tests/tasks/update
HEADERS

AuthToken {YOURTOKENHERE}

BODY formdata

message Do xxx something dasasa
due_date 2020-09-19 12:12:12
optional

priority 2
optional (1: normal, 2: mid, 3: high)

assigned_to 1
optional

taskid 1
AmitabhaGhosh123 2-Nov-20 9:26am View    
Below is the method for api :

updateTask(data) {
return this.http.post(this.apiBaseUrl + '/update', JSON.stringify(data),{
headers: new HttpHeaders({
"authtoken":'MMPIUq9bM8zRUFDWzc7XMMGt8jix38q9',
"content-type": 'application/json',
"accept": 'application/json'
})
})
}

Method for calling the api :

updateTask() {
this.updateObject['taskid'] = this.filteredObject['id'];
this.updateObject['message'] = this.filteredObject['message'];
this.updateObject['due_date'] = this.filteredObject['due_date'];
this.updateObject['priority'] = this.filteredObject['priority'];
this.updateObject['assigned_to'] = this.filteredObject['assigned_to'];
this.spinner.show('spinner1');
var data = [];
data.push(this.updateObject);
this.taskservice.updateTask(data).subscribe(res=>{
console.log(res);
$('#content').modal("hide");
this.spinner.hide('spinner1');
this.fetchAllTasks();
},
(error)=>{
this.spinner.hide('spinner1');
});
}


The api accepts formdata as input in the body section and apikey in headers.
AmitabhaGhosh123 7-Aug-20 11:01am View    
One more question .

Suppose I enter in the terminal node <filename> [2,3,4]

Do you have any idea how to change that into array?
AmitabhaGhosh123 7-Aug-20 11:00am View    
Actually I am taking the input from STDIN so I had to change it to Number before sending it to the recurSum function. Now it is working correctly.
AmitabhaGhosh123 7-Aug-20 10:20am View    
it is working now , but it is not summing up the values.
if I enter 2 , it is printing 21 instead of 3.

that is the below line is concatenating the values, not returning the sum.
return (n + recurSum(n - 1)).