Posts

Showing posts with the label api

Xamarin, redirect to page if status code is not Ok

Xamarin, redirect to page if status code is not Ok I have REST API that returns if user exists or not by email. If user exists and I am getting back status OK from API all works fine, but when API response with 404 my app crash. I can't figure out how to check if status is ok or not before app crash and redirect user to register page in case user is not found by API. Here is code that makes request to api: string getuserUrl = $"https://localhost:99282/api/users/{email}"; var client = new HttpClient(); var uri = new Uri(getuserUrl); var result = await client.GetStringAsync(uri); var userResult = JsonConvert.DeserializeObject<User>(result); return userResult; 1 Answer 1 You can use below code to identify whether the API call is success or not. String URL = "https://localhost:99282/api/users/{email}"; using (HttpClien...

use xlwings to run python code in excel

use xlwings to run python code in excel I have a problem running python code by xlwings in excel. My vba code is: Sub Practice() RunPython ("import practice; practice.getdata()") End Sub My python code is practice.py in pycharm. I use the python code to connect to the deribit api and then use excel to run the python code to download data from deribit api to excel. My python code is the following: import pprint import xlwings as xw import pandas as pd import numpy as np from openpyxl.utils.dataframe import dataframe_to_rows from openpyxl import Workbook from deribit_api import RestClient def getdata(): access_key = "6wvUvxmVSoJq" access_secret = "HQQ7ZTU2ZESOR2UELLVSHCRWSHPP2VYE" url = "https://test.deribit.com" client = RestClient(access_key, access_secret, url) client.index() positions = client.positions() account = client.account() dfp = pd.DataFrame(columns=['Kind', 'Expiry Date', 'Direction', 'Underlying', ...

Twitter api redirect to empty page

Twitter api redirect to empty page In this page: http://branding.cumedia.tv/login.php There are four logging options. All works fine except twitter. They redirects to the profile page, but redirects to an empty page. Why is that? Here is the code for the login page: else if (isset($_GET['method']) && $_GET['method']=='twitter_brand'){ //Successful response returns oauth_token, oauth_token_secret, user_id, and screen_name $connection = new TwitterOAuth($config_twitter_id, $config_twitter_secret, $_SESSION['token'] , $_SESSION['token_secret']); $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']); if($connection->http_code == '200') { //Redirect user to twitter $_SESSION['status'] = 'verified'; $_SESSION['request_vars'] = $access_token; //Insert user into the database $user_info = $connection->get('account/verify_credentials'); $name = explo...

Where Can I Download Rest API [closed]

Where Can I Download Rest API [closed] This might be a stupid question, but a school project I am working on involves us using Java and the Rest API. I can't seem to find where to download the API. Shouldn't it just be a jar file that I add to my build path? I can't seem to find a download anywhere which makes me think I am incredibly confused. Any help would be greatly appreciated. I am sorry if this is a duplicated question, but every single thread I have found is just about downloading a file USING the rest api. Thanks. Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question. You can use Jersey Framework. Add your J2EE Web application to this framework .jersey.github.i...

How to call dynamic url in Guzzle with GET request

How to call dynamic url in Guzzle with GET request I'm using Laravel and Guzzle and i want to call java spring rest api and get result from dynamic url : http://localhost:8080/api/clients/clientAvailability/{id} .With static url (http://localhost:8080/api/clients/clientAvailability/9976 everything works great but for dynamic i don't know how to solve it. Rest api which i want to call Controller (function for call rest api) $url='http://localhost:8080/api/clients/clientAvailability/9976'; try{ $client = new Client(); $response = $client->request('GET', $url); $body = $response->getBody(); $status = 'true'; $message = 'Data found!'; return view('chart.clientProfile', ['clients' => $body]); // is thrown for 400 level errors }catch(ClientException $ce){ $status = 'false'; $message = $ce->getMessage(); $data = ; //In the event of a networking error (connect...