My codes is as follows. I want to get the data in JSON. But the data is coming as XML. How can I solve this problem?
var wc = new SMF.Net.WebClient({
URL:"http://192.168.41.179/TestWS/ws.asmx/myComments",
httpMethod:"GET",
requestHeaders: ["content-type", "application/json"],
onSyndicationSuccess: function(e) {
deger = wc.response;
}
});
wc.run(true);
I solved my problem. We need to use WebAPI for this.
Related
I am trying to fetch a json object from the mongodb using meteor, but I have no clue why I’m unable to do so.
I need it to be a JSON object only.
One of the entries of the collection looks like this:
[Image taken from Meteor Dev Tools]
Link: https://i.stack.imgur.com/BxRmS.png
I’m trying to fetch the value part by passing the name.
Code on front end:
export default withTracker(() => {
let aSub = Meteor.subscribe(‘allEntries’);
return {
aBoundaries: DataCollection.find({}).fetch()
}
})(Component Name);
The Meteor Call Statement on front-end:
dataFromDb = Meteor.call(‘functionToBeCalled’, ‘Sydney’);
Server-side Code:
Meteor.publish(‘allEntries’, function(){
return DataCollection.find();
});
Meteor.methods({
functionToBeCalled(aName){
return DataCollection.find({name: aName});
}
});
Another of my questions is:
Is there any way that we publish only all the names in the beginning and then publish the values on demand?
Thanks for your help in advance!
I have tried this as well, but it did not work:
functionToBeCalled(aName){
var query = {};
query['name'] = aName;
return DataCollection.find(query).fetch();
}
The issue seems to be with query.
Collection.find() returns data with cursor.
To get an array of objects, use Collection.find().fetch(). The jsons are returned as collection of array like [{json1}, {json2}].
If there is a single document, you can access the json using Collection.find().fetch()[0]. Another alternative is to use findOne. Example - Collection.findOne(). This will return a single JSON object.
use Meteor.subscribe('allEntries'), do not assign it to a variable.
Meteor.subscribe is asynchronous, it's best you ensure that your subscriptions are ready before you fetch data.
Log DataCollection.find({}).fetch() to your console
Check this official reference https://docs.meteor.com/api/pubsub.html#Meteor-subscribe.
Your second question isn't that clear.
Just in case anyone comes here to look for the answer ~~~
So... I was able to make it work with this code on the server:
Meteor.methods({
functionToBeCalled(aName){
console.log(aName);
return DataCollection.findOne({name: aName});
}
});
And this on the client:
Meteor.call('functionToBeCalled', nameToBePassed, (error,response) => {
console.log(error, "error");
console.log(response, "response"); //response here
})
Thanks for the help!
I am trying to creating a app which can send posts to tumblr using tumblr.js api.
I could send single image using the createPhotoPost method, but I have to send multiple image in a single post via this method.
From the documentation it says that createPhotoPost method has a "data" parameter which can be an array with "URL-encoded binary contents"
When ever I try to send something in the data Array it returns "[Error: form-data: Arrays are not supported.]".
Can someone please help to solve this issue and please explain what should we pass in the array (Really I am not getting what is URL-encoded binary contents)?
Thanks in advance
There is an error in tumblr.js
https://tumblr.github.io/tumblr.js/tumblr.js.html#line504
The documentation at https://www.tumblr.com/docs/en/api/v2#posting is correct.
Basically the issue is that its not supposed to be
data = [ one , two ] its litterally params['data[0]'] = one ; params['data[1]'] = two; (?A PHP Convention)
var request = require('request')// already a tumblr.js dependency
var currentRequest = request({
url:'https://api.tumblr.com/v2/blog/someblog.tumblr.com/post',
oauth:keys,
},function(err,response,body){
currentRequest//
debugger
cb()
})
var params = {
'type' :'photo',
'caption':'Click To Verify You Are A Robot',
}
var params_images = [
fs.createReadStream('image'),
fs.createReadStream('image')
]
// Sign it with the non-data parameters
currentRequest.form(params)
currentRequest.oauth(keys);
// Clear the side effects from form(param)
delete currentRequest.headers['content-type'];
delete currentRequest.body;
// And then add the full body
var form = currentRequest.form();
//###add params_images to params keys 'data[0]' 'data[1]' 'data[2]' ....
params_images.forEach(function(image,index){
params['data['+index+']']
})
for (var key in params) {
form.append(key, params[key]);
}
// Add the form header back
var form_headers = form.getHeaders()
for(var key in form_headers){
currentRequest[key] = form_headers[key]
}
I'm trying to create a service to write data from a SAPUI5 frontend to HANA tables.
As far as I checked, I believe this is not possible via OData Services. So I've found another way, sing an XSJS file with a SQL INSERT statement.
Now, my problem is using this in UI5. As with OData, I would use something like oModel.create but now I think this doesn't work like that.
Those anyone has a clue?
Thanks!
Eva
UPDATE:
After using the first answer, I tried to create an entry in a HANA Table, but I'm getting a 500 error. Here's the code of the xsjs file:
var data = '', conn = $.db.getConnection(), pstmt;
if($.request.body){
data = $.request.parameters.get("firstName");
}
var conn = $.db.getConnection();
var pstmt = conn.prepareStatement( 'INSERT INTO "Z003HB1N"."T_TEST" (FIRSTNAME) VALUES(?)' );
pstmt.setString(1,data);
pstmt.execute();
pstmt.close();
conn.commit();
conn.close();
doResponse(200,'');
$.response.contentType = 'text/plain';
$.response.setBody('Upload ok');
$.response.status = 200;
Any clue what might be wrong?
You can simply use .ajax calls to call your new oData service on HANA and use parameters to hand over the desired values to your .xsjs service.
Example:
var query = "firstName=Sherlock&lastName=Holmes"
jQuery.ajax({
url : "url/to/your/Service.xsjs?" + query,
success : function(response) {
// will be called once the xsjs file sends a response
console.log(response);
},
error : function(e) {
// will be called in case of any errors:
console.log(e);
}
});
On HANA you can access the provided parameters in your service like this:
var firstName = $.request.parameters.get("firstName");
var lastName = $.request.parameters.get("lastName");
I am using this code to update data of a Parse User, but the data is not updating nor am I able to retrieve the data.
I am able to do update and retrieve the data for a ParseObject class created by me. Can someone tell me where I am wrong on this?
Out of all the debugs I have set I am able to see only the 1st debug "parse GetSync function passed" and the rest are not printing.
var parseUser: ParseUser;
function FBtoParse(){
var query = ParseUser.Query;
query.GetAsync("Q0D9eBvRee").ContinueWith(GetSync);
Debug.Log("parse GetSync function passed");
Debug.Log("Object ID: "+ parseUser["objectId"]);
Debug.Log("username is : "+ parseUser["username"]);
Debug.Log("User Updated");
}
var GetSync = function (t:System.Threading.Tasks.Task.<ParseUser>){
parseUser = t.Result;
};
function OnGUI{
if (GUILayout.Button("Parse"))
{
FBtoParse();
Debug.Log("Pressed Parse");
}
}
Parse at the moment only allows ParseUsers to update their own object through authentication.
https://parse.com/docs/js/guide#users-security-for-user-objects
i have downloaded sample mvc application from here http://ravenmvc.codeplex.com/releases/view/45994
It works just fine. But i have a question. In sample application DocumentId looks like "categories-2", but in my application after i call Store method:
using (var session = DocumentStore.OpenSession())
{
session.Store(item);
session.SaveChanges();
return item;
}
i have DocumentId like "projects/3073". I want to have DocumentId in format just like in sample application. How i can do that? Is there some option i should change?
You need to set the DocumentConvention when you initialize your DocumentStore:
var ds = new DocumentStore();
ds.ConnectionStringName = connectionStringName;
ds.Initialize();
ds.Conventions.IdentityPartsSeparator = "-";