how to convert json response to List in c# RestSharp - sql

Currently I am working on asp .NET 5 console application with Restsharp, My Api Get request is working on postman, but I am struggling to convert this json object to a list .
This is my json object:
"data": {
"domain": "intel.com",
"disposable": false,
"webmail": false,
"accept_all": false,
"pattern": "{first}.{last}",
"organization": "Intel",
"country": "US",
"state": null,
"emails": [
{
"value": "danielle.sikich#intel.com",
"type": "personal",
"confidence": 99,
"sources": [
{
"domain": "github.com",
"uri": "http://github.com/hpc/mpifileutils",
"extracted_on": "2021-10-28",
"last_seen_on": "2021-10-28",
"still_on_page": true
}
],
"first_name": "Danielle",
"last_name": "Sikich",
"position": null,
"seniority": null,
"department": null,
"linkedin": null,
"twitter": null,
"phone_number": null,
"verification": {
"date": "2021-11-05",
"status": "valid"
}
},
I tried this but its not working:
List<Job> JobList = JsonConvert.DeserializeObject<List<Job>>(jsonResponse["data"]["emails"]["value"].ToString());

Related

Microsoft Booking Appointment Graph API -Only Post Request Not working

when I trying to create Microsoft Booking Appointment through Graph API
Only Post Request Not working .
GET , PATCH , DELETE Reuqest are working fine
through postman
same post request is working find on graph explorer platform . but not on posmant with
my auth token
my post API
https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/XXXXXXXXXXXXXXX.com/appointments
and body (took example from here)
excluded optional properties like servicename and customers
{
"#odata.type": "#microsoft.graph.bookingAppointment",
"customerTimeZone": "America/Chicago",
"smsNotificationsEnabled": false,
"endDateTime": {
"#odata.type": "#microsoft.graph.dateTimeTimeZone",
"dateTime": "2023-01-02T14:30:00.0000000",
"timeZone": "UTC"
},
"isLocationOnline": true,
"optOutOfCustomerEmail": false,
"anonymousJoinWebUrl": null,
"postBuffer": "PT10M",
"preBuffer": "PT5M",
"price": 10,
"priceType#odata.type": "#microsoft.graph.bookingPriceType",
"priceType": "fixedPrice",
"reminders#odata.type": "#Collection(microsoft.graph.bookingReminder)",
"reminders": [
{
"#odata.type": "#microsoft.graph.bookingReminder",
"message": "This service is tomorrow",
"offset": "P1D",
"recipients#odata.type": "#microsoft.graph.bookingReminderRecipients",
"recipients": "allAttendees"
},
{
"#odata.type": "#microsoft.graph.bookingReminder",
"message": "Please be available to enjoy your lunch service.",
"offset": "PT1H",
"recipients#odata.type": "#microsoft.graph.bookingReminderRecipients",
"recipients": "customer"
},
{
"#odata.type": "#microsoft.graph.bookingReminder",
"message": "Please check traffic for next cater.",
"offset": "PT2H",
"recipients#odata.type": "#microsoft.graph.bookingReminderRecipients",
"recipients": "staff"
}
],
"serviceId": "XXXXXXXXXXXXXXXXXXXXX",
"serviceLocation": {
"#odata.type": "#microsoft.graph.location",
"address": {
"#odata.type": "#microsoft.graph.physicalAddress",
"city": "Buffalo",
"countryOrRegion": "USA",
"postalCode": "98052",
"postOfficeBox": null,
"state": "NY",
"street": "123 First Avenue",
"type#odata.type": "#microsoft.graph.physicalAddressType",
"type": null
},
"coordinates": null,
"displayName": "Customer location",
"locationEmailAddress": null,
"locationType#odata.type": "#microsoft.graph.locationType",
"locationType": null,
"locationUri": null,
"uniqueId": null,
"uniqueIdType#odata.type": "#microsoft.graph.locationUniqueIdType",
"uniqueIdType": null
},
"serviceNotes": "Customer requires punctual service.",
"startDateTime": {
"#odata.type": "#microsoft.graph.dateTimeTimeZone",
"dateTime": "2023-01-02T14:00:00.0000000",
"timeZone": "UTC"
},
"maximumAttendeesCount": 1,
"filledAttendeesCount": 1
}

POST request failed from Postman to Jdoodle API

I have created an account on jdoodle and buy a free plan in which we can make 200 requests per days and from there I got credentials (clientId and clientSecret) for making request to their api .
I am making post request from postman to Jdoodle api. It is giving me response as unauthorized request with status code 401 in spite of valid credentials.
Giving me unauthorised request error also when i make request for checking credits used or (how many calls I have made to their api).
POST- https://api.jdoodle.com/v1/execute/
{
"clientID" : "83xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"clientSecret" : "30xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"script" : "console.log('hello')",
"language" : "nodejs",
"versionIndex" : "0"
}
Response I am getting is -
{
"error": "Unauthorized Request",
"statusCode": 401
}
POST- https://api.jdoodle.com/v1/credit-spent
{
"clientID" : "83xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"clientSecret" : "30xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
}
Response I am getting is -
{
"error": "Unauthorized Request",
"statusCode": 401
}
I don't know why I am getting such response inspite of all valid credentials and parameters.
Use this postman collection. Mostly it looks like your issue is with auth. make sure if client_id and secret are safely substituted.
{
"auth": null,
"event": null,
"info": {
"_postman_id": null,
"description": null,
"name": "JDoodle Compiler API.http",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"version": null
},
"item": [
{
"description": null,
"event": null,
"id": null,
"name": "Execute Program",
"protocolProfileBehavior": null,
"request": {
"auth": null,
"body": {
"disabled": null,
"file": null,
"formdata": null,
"graphql": null,
"mode": "raw",
"options": {
"language": "json"
},
"raw": "{\"clientId\": \"{{clientId}}\", \"clientSecret\": \"{{clientSecret}}\", \"script\": \"print 'hello'\", \"language\": \"python2\", \"versionIndex\": \"0\"}",
"urlencoded": null
},
"certificate": null,
"description": "Execute Program",
"header": [
{
"description": null,
"disabled": false,
"key": "content-type",
"value": "application/json"
}
],
"method": "POST",
"proxy": null,
"url": "https://api.jdoodle.com/v1/execute/"
},
"response": null,
"variable": null,
"auth": null,
"item": null
}
],
"protocolProfileBehavior": null,
"variable": [
{
"description": null,
"disabled": false,
"id": null,
"key": "baseUrl",
"name": null,
"system": null,
"type": null,
"value": "httpsDefaultParameterValue:DefaultParameterValue#DefaultParameterValue.myshopify.com/"
},
{
"description": null,
"disabled": false,
"id": null,
"key": "id",
"name": null,
"system": null,
"type": null,
"value": "<post>"
},
{
"description": null,
"disabled": false,
"id": null,
"key": "event_id",
"name": null,
"system": null,
"type": null,
"value": "<>"
}
]
}
With dothttp request is far simple and easily sharable
#name("Execute Program")
POST "https://api.jdoodle.com/v1/execute/"
json({
"clientId": "{{clientId}}",
"clientSecret": "{{clientSecret}}",
// "script": '<?php echo "hello"; ?>',
// "language": "php",
"script" :"print 'hello'",
"language": "python2",
// "stdin": "",
"versionIndex": "0"
})

How to get list of Users under a certain Manager/Approver in Coupa API?

I'm lost and I'm hoping that someone may have worked on this before.
So Coupa has its API:
https://coupadocs.atlassian.net/wiki/display/integrate/Users+API
I was able to retrieve user information together with the corresponding manager. Sample response:
https://unknownserver-test.coupahost.com/api/users?employee-number=10003323
[
{
"id": 2756,
"created-at": "2017-03-30T09:29:19-05:00",
"updated-at": "2017-03-31T04:30:53-05:00",
"login": "user1.user1",
"email": "staging23#coupa.com",
"purchasing-user": false,
"expense-user": false,
"sourcing-user": false,
"inventory-user": false,
"employee-number": "10003323",
"phone-work": null,
"phone-mobile": null,
"firstname": "user1",
"lastname": "user1",
"fullname": "user1 user1",
"api-user": false,
"active": false,
"salesforce-id": null,
"account-security-type": 0,
"authentication-method": "coupa_credentials",
"sso-identifier": null,
"default-locale": null,
"default-account": null,
"business-group-security-type": null,
"edit-invoice-on-quick-entry": false,
"avatar-thumb-url": null,
"mention-name": "user1user1",
"company-employee-id": "10003323",
"netsuite-employee-id": "10003323",
"subsidiary": {
"id": 1592,
"external-ref-num": null,
"external-ref-code": "company North America:1"
},
"job-title": {
"id": 2591,
"external-ref-num": null,
"external-ref-code": "VP, Sales"
},
"employee-type": "",
"default-expense-region": "",
"default-geo-spend": "",
"notes": "",
"exclude-from-autosarf": "",
"roles": [
{
"id": 10,
"name": "Expense User"
}
],
"manager": {
"id": 838,
"login": "john.doe",
"email": "staging#coupa.com"
},
"default-currency": {
"id": 1,
"code": "USD"
},
"department": {
"id": 342,
"name": "Sales - Exec:176"
},
"expenses-delegated-to": [],
"can-expense-for": [],
"content-groups": [],
"account-groups": [],
"approval-groups": [],
"working-warehouses": [],
"inventory-organizations": [],
"created-by": {
"id": 2748,
"login": "user1 creator",
"email": "user1.creator#company.com"
},
"updated-by": {
"id": 2748,
"login": "user1 creator",
"email": "user1.creator#company.com"
}
}
]
What I've tried are these:
https://unknownserver-test.coupahost.com/api/users?user[manager][id]=838&return_object=shallow
https://unknownserver-test.coupahost.com/api/users?manager[id]=838&return_object=shallow
https://unknownserver-test.coupahost.com/api/users?users[user][manager][id]=838&return_object=shallow
https://{{URL PREFIX}}.{{HOST}}.com/api/users?manager_id=838&return_object=shallow
If you only need the IDs of the users, you'd get better performance with return_object=limited
If there are more than 50 users returned, you'll have to paginate with the offset query param.

Access subscription details with Stripes Webhooks PHP

I haven't been able to find any details for this with PHP, so I am hoping somebody can help me complete this script?
I am searching for the Subscription details from the Stripe API Webhook event. The event I am working on is invoice.payment_succeeded although I am struggling to access the subscription information from this. Here is the test event in full:
{
"id": "evt_19HdmRL346436RYAmvgxkr",
"object": "event",
"api_version": "2016-07-06",
"created": 1479580899,
"data": {
"object": {
"id": "in_19HdmRLniq434634643dO2gU",
"object": "invoice",
"amount_due": 700,
"application_fee": null,
"attempt_count": 1,
"attempted": true,
"charge": "ch_19Hdm3463464365IDDXX",
"closed": true,
"currency": "gbp",
"customer": "315464619",
"date": 1479580899,
"description": null,
"discount": null,
"ending_balance": 0,
"forgiven": false,
"lines": {
"object": "list",
"data": [
{
"id": "sub_9apRC346346CMNg",
"object": "line_item",
"amount": 700,
"currency": "gbp",
"description": null,
"discountable": true,
"livemode": false,
"metadata": {
"website_ref": "Z8ckRo2x",
"user_id": "1"
},
"period": {
"start": 1479580899,
"end": 1482172899
},
"plan": {
"id": "AdFree",
"object": "plan",
"amount": 700,
"created": 1479261871,
"currency": "gbp",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"name": "AdFree",
"statement_descriptor": "SNAPPYSITES ADFREE",
"trial_period_days": null
},
"proration": false,
"quantity": 1,
"subscription": null,
"type": "subscription"
}
],
"has_more": false,
"total_count": 1,
"url": "/v1/invoices/in_19HdmRLn34353465dO2gU/lines"
},
"livemode": false,
"metadata": {},
"next_payment_attempt": null,
"paid": true,
"period_end": 1479580899,
"period_start": 1479580899,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": null,
"subscription": "sub_9a2552OA5553MNg",
"subtotal": 700,
"tax": null,
"tax_percent": null,
"total": 700,
"webhooks_delivered_at": null
}
},
"livemode": false,
"pending_webhooks": 1,
"request": "req_9apRx9555ZVm55",
"type": "invoice.payment_succeeded"
}
I am currently listening with this unfinished script:
$input = #file_get_contents("php://input");
$event_json = json_decode($input);
$event_id = $event_json->id;
$event = \Stripe\Event::retrieve($event_id);
if($event->type == 'invoice.payment_succeeded'){
$invoice = $event->data->object;
$subscription = $invoice->lines->data->plan;
$customer = \Stripe\Customer::retrieve($invoice->customer);
print_r($subscription);
}
Unfortunately I'm not getting any response from the $subscription array. And I have attempted various methods, such as; $subscription = $invoice->plan; or $subscription = $invoice->data->plan; etc...
I do receive data for $invoice & $customer so I know they both function correctly. My main focus is to retrieve the Metadata information:
"metadata": {
"website_ref": "Z8ckRo2x",
"user_id": "1"
}
So I know which account this payment relates to. Hoping somebody might know what I'm doing wrong.
Have you tried $invoice->lines->data->Metadata->website_ref to get the metadata you are after?
Your Invoice consists of a list of subscriptions, in this case just 1. Each subscription is a result of the user selecting a plan. The metadata is stored at the subscription level as it's specific for the customer, not on the plan.

add tracking to mandrill send-template

My mandrill keeps saying my message is not opened when I call messages/info.json despite I have added tracking.
here is my request:
{
"key": "mykey",
"template_name": "message",
"template_content": {},
"message": {
"html": null,
"text": null,
"subject": "test",
"from_email": "info#test.io",
"from_name": "test",
"to": [
{
"email": "rob.proesmans#test.be",
"name": "rob",
"type": "to"
}
],
"headers": null,
"important": null,
"track_opens": true,
"track_clicks": true,
etc..
my mandrill response when i call /messages/info.json
{
"ts": 1455290984,
"_id": "3e5877fc43044841ab505f999b4a5b00",
"state": "sent",
"subject": "test",
"email": "rob.proesmans#redtree.be",
"tags": {},
"opens": 0,
"clicks": 0,
"smtp_events": [
{
"ts": 1455290986,
"type": "sent",
"diag": "250 2.0.0 OK 5E/A9-30218-21AFDB65",
"source_ip": "198.2.134.26",
"destination_ip": "94.143.184.119",
"size": 23062
}
],
"resends": {},
"sender": "info#redtree.io",
"template": "pocmessage",
"opens_detail": {},
"clicks_detail": {}
}
After 5minutes.. still no result after opening the mail..
What am i doing wrong?
Thank you
I takes around 2 hours till Mandrill knows when your mail is opened.