Kod Kütüphanesi
You may want to provide examples of code that will give developers a headstart creating their applications.
C# Sample Code
using System;using System.Text;using System.Net;using System.Security.Policy;using System.IO;using System.Web;using RestSharp;namespace SampleConsoleApplication{ class ApiExplorer { static void Main(string[] args) { StringBuilder urlBuilder = new StringBuilder("https://apitest.anadoluhayat.com.tr/api/respondBulkCustomerInfo"); Url url = new Url(urlBuilder.ToString()); var client = new RestClient(url.Value); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer 1b16188e-430b-4b6b-b64b-a7781df160e8");request.AddHeader("Content-Type", "application/json"); request.AddParameter("body", "{ \"batchId\":\"70760\", \"taxNumber\":\"7195808270\"}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); } }}
Java Sample Code
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStream;import java.net.HttpURLConnection;import java.net.URL;public class ApiExplorer { public static void main(String[] args) throws IOException { StringBuilder urlBuilder = new StringBuilder("https://apitest.anadoluhayat.com.tr/api/respondBulkCustomerInfo"); URL url = new URL(urlBuilder.toString()); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Authorization", "Bearer 1b16188e-430b-4b6b-b64b-a7781df160e8"); conn.setRequestProperty("Content-Type", "application/json"); byte[] body = "{ \"batchId\":\"70760\", \"taxNumber\":\"7195808270\"}".getBytes(); conn.setFixedLengthStreamingMode(body.length); conn.setDoOutput(true); OutputStream out = conn.getOutputStream(); out.write(body); System.out.println("Response code: " + conn.getResponseCode()); BufferedReader rd; if(conn.getResponseCode() >= 200 && conn.getResponseCode() <= 300) { rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); } else { rd = new BufferedReader(new InputStreamReader(conn.getErrorStream())); } StringBuilder sb = new StringBuilder(); String line; while ((line = rd.readLine()) != null) { sb.append(line); } rd.close(); conn.disconnect(); System.out.println(sb.toString()); }}
PHP Sample Code
$ch = curl_init();$url = 'https://apitest.anadoluhayat.com.tr/api/respondBulkCustomerInfo';curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);curl_setopt($ch, CURLOPT_HEADER, FALSE);curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');curl_setopt($ch, CURLOPT_POSTFIELDS, '{ "batchId":"70760", "taxNumber":"7195808270"}');curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer 1b16188e-430b-4b6b-b64b-a7781df160e8','Content-Type: application/json'));$response = curl_exec($ch);curl_close($ch);var_dump($response);
JavaScript Sample Code
var xhr = new XMLHttpRequest();var url = 'https://apitest.anadoluhayat.com.tr/api/respondBulkCustomerInfo';xhr.open('POST', url);xhr.setRequestHeader('Authorization', 'Bearer 1b16188e-430b-4b6b-b64b-a7781df160e8');xhr.setRequestHeader('Content-Type', 'application/json');xhr.onreadystatechange = function () { if (this.readyState == 4) { alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText); }};xhr.send('{ "batchId":"70760", "taxNumber":"7195808270"}');