Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $username = ...
- $password = ...
- $credentials = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($username + ":" + $password))
- $method = "getReadingsBySensor"
- $sensorId = 621
- $count = 10
- $url = "http://localhost:60023/api/$method?id=$sensorId&count=$count"
- Invoke-WebRequest -Uri $url -Headers @{Authorization = "Basic $credentials"} | ConvertFrom-Json
- $url = "https://example.com/api/$method?=id=$sensorId&count=$count
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Web;
- using System.Web.Http;
- using ..
- namespace MyApp.Controllers
- {
- public class GetReadingsBySensorController : ApiController
- {
- internal new static User User;
- // GET
- public ICollection<Readings.ReadingsBySensor> Get(int id, int count = 1)
- {
- // authenticate user
- User = ApiAuthentication.AuthUser(HttpContext.Current);
- /* do stuff to get readings */
- return new List<Readings.ReadingsBySensor>()
- {
- readings
- };
- }
- }
- }
Add Comment
Please, Sign In to add comment