Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hi there,
Trying to do the Get Request with the Form Data but that is not working in the TWX. But in the PostMan, it gives me an 200 Ok Response.
Postman Form-Data:
How this Form data can be used in the Get Request in Thingworx Service.
@slangley
Thanks,
Shashi.
Solved! Go to Solution.
This is fixed by following code
var TableData = me.GetDataTableEntries({
maxItems: undefined /* NUMBER {"defaultValue":500} */
});
var content = "grant_type=" + TableData.grant_type + "&client_id=" + TableData.client_id + "&client_secret=" + TableData.client_secret;
params = {
proxyScheme: "https" /* STRING {"defaultValue":"http"} */ ,
url: "https://***********" /* STRING */ ,
content: content /* STRING */ ,
contentType: "application/x-www-form-urlencoded" /* STRING */ ,
};
// response : STRING
response = Resources["ContentLoaderFunctions"].PostText(params);
result = JSON.parse(response);
This is Thingworx Service Code, But doesn't work.
var table = Resources["InfoTableFunctions"].CreateInfoTable();
table.AddField({name: "form-data", baseType: "JSON"});
table.AddRow({
"form-data" :
{
grant_type : "*********",
client_id : "*********"",
client_secret : "*********"",
resource : "*********""
}
});
let params = {
proxyScheme: "https" /* STRING {"defaultValue":"http"} */,
headers: {"Content-Type" : "multipart/form-data", "Accept": "*/*"} /* JSON */,
ignoreSSLErrors: undefined /* BOOLEAN */,
useNTLM: undefined /* BOOLEAN {"defaultValue":false} */,
partsToSend: table /* INFOTABLE */,
workstation: undefined /* STRING {"defaultValue":""} */,
useProxy: undefined /* BOOLEAN {"defaultValue":false} */,
repository: undefined /* STRING */,
proxyHost: undefined /* STRING {"defaultValue":""} */,
url: "*********"" /* STRING */,
timeout: undefined /* NUMBER {"defaultValue":60} */,
proxyPort: undefined /* INTEGER {"defaultValue":8080} */,
password: undefined /* STRING */,
pathOnRepository: undefined /* STRING */,
domain: undefined /* STRING {"defaultValue":""} */,
username: undefined /* STRING */
};
// result: JSON
let result = Resources["ContentLoaderFunctions"].PostMultipart(params);
This is fixed by following code
var TableData = me.GetDataTableEntries({
maxItems: undefined /* NUMBER {"defaultValue":500} */
});
var content = "grant_type=" + TableData.grant_type + "&client_id=" + TableData.client_id + "&client_secret=" + TableData.client_secret;
params = {
proxyScheme: "https" /* STRING {"defaultValue":"http"} */ ,
url: "https://***********" /* STRING */ ,
content: content /* STRING */ ,
contentType: "application/x-www-form-urlencoded" /* STRING */ ,
};
// response : STRING
response = Resources["ContentLoaderFunctions"].PostText(params);
result = JSON.parse(response);