API پارسااسپیس۳

shape
shape
shape
shape
shape
shape
shape
shape

در مقاله قبل در مورد API پارسااسپیس 1 و API پارسااسپیس 2 صحبت کردیم در این مقاله در مورد API پارسااسپیس3 توضیح میدهیم.

پوشه جدید

ساخت پوشه جدید با مسیر یا نام دلخواه(API پارسااسپیس3).

آدرس (Url) :

https://api.parsaspace.com/v1/files/Createfolder

API پارسااسپیس3

نمونه پاسخ دریافتی:

{“result”:”success”}

نمونه کد زیان های برنامه نویسی :

.NET

var client = new RestClient(“http://api.parsaspace.com/v1/files/rename”);
var request = new RestRequest(Method.POST);
request.AddHeader(“authorization”,”Bearer yourtoken”);
request.AddHeader(“content-type”, “application/x-www-form-urlencoded”);
request.AddParameter(“domain”,”yourdomain”);
request.AddParameter(“path”,”/”);
IRestResponse response = client.Execute(request);

PHP

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => “http://api.parsaspace.com/v1/files/createfolder”,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => “path=%2Fhello&domain=yourdomain&type=json”,
CURLOPT_HTTPHEADER => array(
“authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1bmlxdWVfbmFtZSI6InNhZWlkbWFyb3VmaTY2QGd”,
“cache-control: no-cache”,
“content-type: application/x-www-form-urlencoded”,
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo “cURL Error #:” . $err;
} else {
echo $response;
}

JAVA

HttpResponse response = Unirest.post(“http://api.parsaspace.com/v1/files/createfolder”)
.header(“content-type”, “application/x-www-form-urlencoded”)
.header(“authorization”, “Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1bmlxdWVfbmFtZSI6InNhZWlkbWFyb3VmaTY2QGd”)
.body(“path=%2Fhello&yourdomain&type=json”)
.asString();

python

import requests

url = “http://api.parsaspace.com/v1/files/createfolder”

payload = “path=%2Fhello&yourdomain&type=json”
headers = {
‘content-type’: “application/x-www-form-urlencoded”,
‘authorization’: “Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1bmlxdWVfbmFtZSI6InNhZWlkbWFyb3VmaTY2QGd”,
}

esponse = requests.request(“POST”, url, data=payload, headers=headers)

print(response.text)

Node.js

var request = require(“request”);
var options = { method: ‘POST’,
url: ‘http://api.parsaspace.com/v1/files/createfolder’,
headers:
{
authorization: ‘Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1bmlxdWVfbmFtZSI6InNhZWlkbWFyb3VmaTY2QGd’,
‘content-type’: ‘application/x-www-form-urlencoded’ },
form: { path: ‘/hello’, domain: ‘yourdomain’, type: ‘json’ } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});

نمونه پاسخ ( خطاها

خطا 200

{
“result”: “ok,
}

خطا 400

{
“result”: “error” ,
“message”: “Object already exist.”,
}

خطا 403

{
“result”: “error” ,
“message”: “Sorry!Access denied”,
}

کلام آخر : جهت استفاده و مطالعه لطفا به منبع ومقاله زیر مراجعه نمائید .

 

منبع

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *