I'm using a .NET Core console application to send JSON data to an Azure Logic App. If the JSON data is a short list of data e.g. 4 items then everything works. For more data I have to evaluate the Content of the HttpRequestMessage before sending otherwise the Azure Logic App reports empty content. Is there any alternative to forcing evaluation, it feels counter intuitive.
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var postRequest = new HttpRequestMessage(HttpMethod.Post, uri)
{
Content = JsonContent.Create(data)//data is a list object
};
//need this line to evaluate the content before posting otherwise content is empty according to Azure Logic App
await postRequest.Content.ReadAsStringAsync();
using var postResponse = await httpClient.SendAsync(postRequest);
postResponse.EnsureSuccessStatusCode();
This code structure seems to feature in a lot of tutorials without the call to postRequest.Content.ReadAsStringAsync() without anyone experiencing similar problems.
An example of the JSON that fails would be:
[{"runDate":"2021-02-18T16:30:11.23","name":"AuditLog","rows":3859209,"reservedKb":22061528,"dataKb":8781560,"reservedIndexSize":66328,"reservedUnused":13213640,"dbName":"DBOne"},{"runDate":"2021-02-18T16:30:11.23","name":"AnswerData","rows":70167,"reservedKb":12586736,"dataKb":12494912,"reservedIndexSize":1472,"reservedUnused":90352,"dbName":"DBOne"},{"runDate":"2021-02-18T16:30:11.23","name":"Data_import","rows":3623146,"reservedKb":722632,"dataKb":379704,"reservedIndexSize":1424,"reservedUnused":341504,"dbName":"DBOne"},{"runDate":"2021-02-18T16:30:11.23","name":"Answers","rows":2036892,"reservedKb":528872,"dataKb":270096,"reservedIndexSize":257360,"reservedUnused":1416,"dbName":"DBOne"},{"runDate":"2021-02-18T16:30:11.23","name":"Data","rows":3623146,"reservedKb":381256,"dataKb":379704,"reservedIndexSize":1424,"reservedUnused":128,"dbName":"DBOne"},{"runDate":"2021-02-18T16:30:11.23","name":"Data_backup","rows":3623146,"reservedKb":380048,"dataKb":379704,"reservedIndexSize":16,"reservedUnused":328,"dbName":"DBOne"},{"runDate":"2021-02-18T16:30:11.23","name":"datadec","rows":3623146,"reservedKb":252168,"dataKb":232952,"reservedIndexSize":8,"reservedUnused":19208,"dbName":"DBOne"},{"runDate":"2021-02-18T16:30:11.23","name":"SalesDetails","rows":84168,"reservedKb":170496,"dataKb":138104,"reservedIndexSize":20136,"reservedUnused":12256,"dbName":"DBOne"},{"runDate":"2021-02-18T16:30:11.23","name":"OurUsers","rows":66145,"reservedKb":72240,"dataKb":37880,"reservedIndexSize":32776,"reservedUnused":1584,"dbName":"DBOne"},{"runDate":"2021-02-18T16:30:11.23","name":"Orders","rows":362720,"reservedKb":70016,"dataKb":53608,"reservedIndexSize":11976,"reservedUnused":4432,"dbName":"DBOne"},{"runDate":"2021-02-18T16:30:11.597","name":"CustDetails","rows":8949,"reservedKb":16392,"dataKb":15704,"reservedIndexSize":80,"reservedUnused":608,"dbName":"DBTwo"},{"runDate":"2021-02-18T16:30:11.597","name":"OurUsers","rows":5580,"reservedKb":6096,"dataKb":4456,"reservedIndexSize":1600,"reservedUnused":40,"dbName":"DBTwo"},{"runDate":"2021-02-18T16:30:11.597","name":"Answers","rows":56835,"reservedKb":5184,"dataKb":5104,"reservedIndexSize":32,"reservedUnused":48,"dbName":"DBTwo"},{"runDate":"2021-02-18T16:30:11.597","name":"UserRoles","rows":5577,"reservedKb":4632,"dataKb":1496,"reservedIndexSize":3056,"reservedUnused":80,"dbName":"DBTwo"},{"runDate":"2021-02-18T16:30:11.597","name":"CustDetails","rows":5866,"reservedKb":1928,"dataKb":1864,"reservedIndexSize":16,"reservedUnused":48,"dbName":"DBTwo"},{"runDate":"2021-02-18T16:30:11.597","name":"OrderHistories","rows":6102,"reservedKb":1224,"dataKb":1168,"reservedIndexSize":16,"reservedUnused":40,"dbName":"DBTwo"},{"runDate":"2021-02-18T16:30:11.597","name":"Orders","rows":6196,"reservedKb":1224,"dataKb":1176,"reservedIndexSize":16,"reservedUnused":32,"dbName":"DBTwo"},{"runDate":"2021-02-18T16:30:11.597","name":"Transfers","rows":7522,"reservedKb":840,"dataKb":816,"reservedIndexSize":16,"reservedUnused":8,"dbName":"DBTwo"},{"runDate":"2021-02-18T16:30:11.597","name":"SalesDetails","rows":8762,"reservedKb":648,"dataKb":576,"reservedIndexSize":16,"reservedUnused":56,"dbName":"DBTwo"},{"runDate":"2021-02-18T16:30:11.597","name":"TransferAdvice","rows":13706,"reservedKb":392,"dataKb":328,"reservedIndexSize":16,"reservedUnused":48,"dbName":"DBTwo"}]
I want to create a html page which synchronize JSON data with pouch Db.
The JSON data is a response from a web service.I have created a sample html file which can create a pouch Db database.I have created rest web service which gives certain data as response. can any one help me to synchronize these two.
PouchDB has a built in method for synchronizing with CouchDB using one- or two-way replication.
I understand that you want to sync with a datasource, which doesn't have a CouchDB compatible API. Then you'll have to write code to perform the synchronization with your specific JSON API.
There's a library now which makes it possible to import a JSON string (dump) as database into PouchDB.
It's called PouchDB-Load and is written by PouchDB author Nolan Lawson.
So in your case the code can be as simple as:
var db = new PouchDB('my-awesome-db');
db.load('http://example.com/my-dump-file.json').then(function () {
// done loading!
}).catch(function (err) {
// HTTP error or something like that
});
I am creating a mobile app using Titanium. I am using the titanium db which is sqlite. This pdf needs to have boxes to structure the data and images that I am taking with the app as well.
I am assuming what I need to do is convert the data into json on titanium, upload it to a web server and insert into a mysql/phpmysql db and then use some sort of script that is out there will read the web db and create a pdf and send it back to the phone
is that right?
and if so...i need help with that whole process haha...any good tutorials on db upload to web db process?
Check the docs, HTTPClient is what you need to use, its a standard.
First steps would be to create a web service on your server that parses your JSON formatting. The bulk of the work you would have to do has nothing to do with Titanium, but here is the code for sending a JSON object to some web service with a POST from a Titanium App.
var xhr_getstep = Titanium.Network.createHTTPClient();
xhr_getstep.onload = function(e) {
// Do something with the response from the server
var responseBlob = this.responseText;
};
xhr_getstep.onerror = function() {
Ti.API.info('[ERROR] WebService failed.');
};
xhr_getstep.open("POST", 'http://yourwebsite.com/yourwebserviceentry.php');
xhr_getstep.setRequestHeader("Content-Type", "application/json");
// Create your object with info on how to create the PDF
var objSend = {title : 'Amazing Title'};
xhr_getstep.send(obj); // Send it all off