swift 3: connect to database using json format - json

I want to POST a JSON web request to the webserver through an ios application when I press on a button.
Now, there is a field in the database of the webserver, and the field is initialised with the value false. When the button is pressed in the app (meaning: when the POST request reaches the webserver), I have to change that fields value into true.
Can you please give me a code or a video that can help me to do this?

Related

Logic Apps - Data Operations Parse JSON not parsing Content from Event Hub

I am trying to create a logic app that connects to event hub and sends an email whenever an event is added to the event hub.
I was able to get it working when connecting EH to outlook connectors. I want to be able to parse the data and extract certain fields from the event content. I look up online to use Parse JSON from the Data Operations action but it seems not to be able to parse the content
I tried using Body as the input and it succeeds but the event fields are empty, indicating me that it not getting the event data.
Any ideas?
I have a test and reproduce your problem, suppose your content-type is application/octet-stream, if yes the content will be encoded with base64, then the Parse_JSON input content should be decodeBase64(triggerBody()?['ContentData']).
Also you could change the content type to application/json or text/plain, it will just work.

How to use Twilio on REST client like Postman

Now I am at Stack Overflow as I could not get a simple answer elsewhere for my problem.
I need to send multiple messages with Twilio using Postman. I need to know the script and procedure how to do it. I would prefer JSON(application/json) under body>raw. And I would request if a screencast can be added to it.
Thanks in advance.
Open Postman, new tab for a new request
Select POST from the request type drop-down
Enter request URL
https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages
(replace ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX with YOUR_TWILIO_ACCOUNT_SID)
Click on Authorization tab (it's under the request type drop-down) and then for the type select Basic Auth and you will see two fields Username and Password
Enter YOUR_TWILIO_ACCOUNT_SID for Username and YOUR_TWILIO_AUTH_TOKEN for Password
Next, click on the Body tab and make sure form-data is selected from the radio buttons. Here you need to enter Key Value pairs like in the picture below (but replace with your values, From must be your Twilio number):
Of course, click on the blue Send button

Sequence of events for Fuzzy search on html page

I have a page html let's call it abc.html
There are AngularJS fields embedded in it.
I am now writing a GET and POST in scala which routes the fuzzy search arguments to the proper page on the server.
I am trying to understand the sequence in which things occur in order to implement a GET/POST requests (written in scala) which would happen when someone makes a search on the search bar on the abc.html page, and which would return elements from the database
Is it abc.html (search) --> http GET request --> backend ( AngularJS) --> Database?
In this case this would mean my http post or get request would pass in the html data model elements which would in turn hit the backend AngularJS controller page which in turn would hit the database, and the return ride would send the database results via an http request to the page?
Do I need to explicitly define my GET in terms of angular fields and the database model?
thanks
HTTP uses request-response pairs. This means you don't have to make another request to return anything to the client, you just need to write the proper response. Other than that, your idea is fundamentally right. The process would look something like this:
Type something into the search form on your HTML page
Submit the search form to your backend. This creates a GET or POST request depending on your form element's method attribute.
(At this point the browser is awaiting a response)
As the request reaches the server, your backend code can capture its data and make a query to your database.
(At this point the server is awaiting data from the database)
The database returns its results, your backend code is free to format it into a response to the client's original request.
The client receives the response and you can use your frontend code to display it to the user.

Swift Login enter MySql

Can't figure it out how to do this:
I have a login form ( no need to register ) which have 2 field. When the user write in this field and push "Login" button the app check in the web mysql database if there is the field, if yes go next page if not print the error message. My problem is to pick the informations from the database.
You need to build a webservice to query an external database like MySQL in this case. Your app should have a way to collect the iphone input for login and then send the data to an api to query and return the result of the request to the iphone.

webRequest API not capturing all page requests from application

I am trying to download JSON data from a web application. The URL/API is static and I can use it to call the webpage that returns the data. There is a session variable parameter that needs to be added to the URL/API call to connect to the server and download the JSON data which is created when you launch the application, but times out if the application is not actively used. My current process is to open the developer tools, launch the web application and when the specific JSON request is made I copy the parameter value then add it to a script that mimics the page request and downloads the JSON data.
I am trying to avoid manually copying and pasting this session variable parameter. I want to be able to automatically capture the web request, parse out the value that I need, set a cookie on my machine and then pick up the cookie by a php script to initiate the JSON data download with the valid session value.
I have looked into creating an extension in chrome using the chrome.webRequest.onResponseStarted with the following code:
chrome.webRequest.onCompleted.addListener(function(details) {
console.log(details);
chrome.cookies.set(
{ url: "http://localhost/MySite/", name: "MyCookie", value: "Tested" }
);
}, {urls:["<all_urls>"]} );
This code works for the main web requests but it doesn’t pick up all the JSON data requests that are made by the application. The application is swf format which is most likely the problem, but I can see the requests in the Network Panel tab of the Developer Tools and they are captured using chrome://net-internals which that leads me to believe that I should be able to capture them somehow.
I have looked into chrome.devtools.network but I cannot seem to figure out how that is supposed to work. Any advice or direction would be greatly appreciated.