How to POST data to an API

I POST some data to an API using POSTMAN. (screenshot attached) like this …

Objective : Now I’m trying to do the same i.e POST the same through Angular js 1.3 code.

Problem : In POSTMAN (shown in pic). I select x-www-form-urlencoded to send data.

Likewise in Angular JS 1.3 How do I send x-www-form-urlencoded ?

Here is the Angular code. I am not sure where to put x-www-form-urlencoded in this code.

var callTokenAPI = function (dataObj) {
		console.log("Call server dataObj =" + angular.toJson(dataObj));
                return $http({
			url: tokenAPIurl,
			method: 'POST',
			data: dataObj,
			headers: { "Content-Type": "application/json;charset=utf-8"  }
		});
};

The default should be “application/x-www-form-urlencoded”, meaning you don’t need to specify it specifically.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.