I'm using the FullContact Card Reader API. From what I can tell when making a request to process a business card I need to send the FullContact API a image of a business card along with a webhook.
sending script:
<?php
$APIkey = 'my FullContact api key';
$callback_url = 'https://www.my-domain.com/my-callback-listener.php';
$url = "https://api.fullcontact.com/v2/cardReader?format=json&webhookUrl=$callback_url;
$imageAsBase64 = base64_encode(file_get_contents('path-to-image-including-extension'));
$requestBody = array();
$requestBody['front'] = $imageAsBase64;
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, $url);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($connection, CURLOPT_POST, true);
curl_setopt($connection, CURLOPT_POSTFIELDS, json_encode($requestBody));
curl_setopt($connection, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'X-FullContact-APIKey: $APIkey'));
$result = curl_exec($connection);
echo json_encode(array('result' => $result));
?>
callback listener script:
<?php
header('HTTP/1.1 200 OK');
?>
I know the sending script is working because the curl result contains an id assigned by the FullContact API. Then, when I reference that id by manually typing the following url into my browser:
https://api.fullcontact.com/v2/cardReader/{id-assigned-from-FullContact}?apiKey={my-FullContact-api-key}
This is what I receive:
{
"id": "id-assigned-from-FullContact",
"lastWebhookAttempt": "2017-03-20T18:41:57.000Z",
"vCardUrl": "https://d1h3f0foa0xzdz.cloudfront.net/2971518/special-link-to-vcf-card.vcf",
"status": "CALLBACK_FAILED",
"webhookAttempts": 5,
"webhookUrl": "https://www.my-domain.com/my-callback-listener.php",
"quality": "LOW",
"submitted": "2017-03-20T18:28:27.000Z",
"contact": {
"photos": [{
"primary": true,
"value": "https://d1h3f0foa0xzdz.cloudfront.net/2971518/special-link-to-image-of-business-card.png",
"type": "BusinessCard"
}],
"organizations": [{
"title": "Senior Sales Consultant",
"isPrimary": true,
"name": "Company ABC"
}],
"name": {
"middleName": null,
"honorificPrefix": null,
"familyName": "Meek",
"givenName": "Jack",
"honorificSuffix": null
},
"emails": [{
"value": "person#something.com",
"type": "Work"
}],
"phoneNumbers": [
{
"value": "+1 123-987-6543 ext. 5159069",
"type": "Work"
},
{
"value": "+1 123-456-6789",
"type": "Mobile"
},
{
"value": "886 123-4567",
"type": "Work Fax"
}
],
"addresses": [{
"region": null,
"streetAddress": "1234 Nowhere Dr,",
"formatted": null,
"postalCode": "48377",
"extendedAddress": null,
"locality": "Novi",
"type": "Work",
"country": "United States"
}]
}
}
You can see in the above result the FullContact API is making 5 attempts to call my callback listener script ultimately resulting in CALLBACK_FAILED. However, my callback script only contains HTTP/1.1 200 OK which should work just fine. This tells me my callback script is not reachable for some reason. My site is being hosted on GoDaddy using their shared hosting platform SSL.
Anyone know if GoDaddy blocks certain webhook traffic? Any help would be appreciated!
I tried reviewing the FullContact documentation but, it failed to provide any clear detail on how there webhooks send back data.
So I ended up reaching out to both my web host (GoDaddy) and FullContact. I have a shared hosting platform with GoDaddy so they restrict a ton of port numbers. FullContact assured me they only use either port 80 or 443.
To solve this one I ended up having to create a local xampp server and make it publicly available. Then I directed FullContact to use my local server as my webhook.
I ran a few tests and used php to pull the ip address, host name, and port number. Here are the results:
Test 1.
Host address: 52.70.48.63
host name: ec2-52-70-48-63.compute-1.amazonaws.com
port#: 63498
Test 2.
Host address: 52.70.48.63
host name: ec2-52-70-48-63.compute-1.amazonaws.com
port#: 4169
Test 3.
Host address: 52.70.48.63
host name: ec2-52-70-48-63.compute-1.amazonaws.com
port#: 61425
All the port number returned are blocked by GoDaddy. The only way for me to receive data back from FullContact was to use my local server. Case Closed. Hope This ended up helping someone someday!
Related
I'm a newbie with Azure DevOps API, and for a future migration case, I want to create new users on my Azure DevOps organization. The users is Azure Active Directory users.
So I tried to do it with that documentation : https://learn.microsoft.com/en-us/rest/api/azure/devops/graph/users/create?view=azure-devops-rest-6.0
The body of my API request look like this:
{
"principalName": "test_user#company.com"
}
It return a status 201 (created) with this informations (for security reason i've put '.' on some lines):
{
"subjectKind": "user",
"metaType": "member",
"directoryAlias": "test_user",
"domain": "....",
"principalName": "test_user#company.com",
"mailAddress": "test_user#company.com",
"origin": "aad",
"originId": "....",
"displayName": "test user",
"_links": {
"self": {
"href": "....."
},
"memberships": {
"href": "....."
},
"membershipState": {
"href": "...."
},
"storageKey": {
"href": "...."
},
"avatar": {
"href": "...."
}
},
"url": "....",
"descriptor": "....."
}
But when I look on the organization users, I don't see any users who was created.
Did I miss something ? When I list users thourgh API it don't appear either...
Thanks in advance for your help.
P.S: It work well in the graphic UI.
Ok, I've finaly solve my own problem...
The parameter groupDescriptors is mandatory in the HTTP request in order to activate the account.
The command should look like that:
https://vssps.dev.azure.com/{{COMPANY}}/_apis/graph/users?groupDescriptors=vssgp.{{GROUPDESCRIPTORS}}&api-version=6.0-preview.1
If you don't add the user to a group when you do the creation, he will not be able to connect.
Get the group descriptor:
https://vssps.dev.azure.com/{{COMPANY}}/_apis/graph/groups?api-version=5.1-preview.1
Hope this will help someone else in the internet.
I'm successfully creating PR requests in Azure DevOps using API-call.
However, I would like to add the reviewer's name to my PR. As per the sample in the link, I have to add the reviewer id in the body.
So, my question is how to dynamically find the reviewer's id prior to submitting the PR from my project? I was following Pull Request Reviewers and nothing seems coming up to provide me the id based on name.
As per branch policy, I have to add 2 reviewers' name.
{
"sourceRefName": "refs/heads/npaulk/my_work",
"targetRefName": "refs/heads/new_feature",
"title": "A new feature",
"description": "Adding a new feature",
"reviewers": [
{
"id": "d6245f20-2af8-44f4-9451-8107cb2767db"
}
]
}
Like #Krzysztof Madej suggested in his answer, you can use the Subject Query endpoint to search and get the GraphSubject response.
However, the Id values in the GraphSubject response does not work for the IdentityRef Id used as parameter for the Pull Request Reviewers endpoint (used to add Reviewers to an existing pull request).
To get the correct IdentityRef Id, you need to do a GET on the URL from the storageKey.href value in the GraphSubject Response. E.g.:
"storageKey": {
"href": "https://vssps.dev.azure.com/thecodemanual/_apis/Graph/StorageKeys/msa.MDQ5MGM0N2ItODNiNC03MmEzLTk2MzgtZTJhMmNjOTY3NWQ3"
},
The response should look something like this:
"value": "73b67dcb-6969-62f2-8075-99834ae11234",
"_links": {
"self": {
"href": "https://vssps.dev.azure.com/thecodemanual/_apis/Graph/StorageKeys/msa.MDQ5MGM0N2ItODNiNC03MmEzLTk2MzgtZTJhMmNjOTY3NWQ3"
},
"descriptor": {
"href": "https://vssps.dev.azure.com/thecodemanual/_apis/Graph/Descriptors/73b67dcb-6969-62f2-8075-99834ae11234"
}
}
The GUID for value is what you use for IdentityRef.Id. The payload to POST to the Pull Request Reviewers endpoint would look something like this:
[
{
"id": "73b67dcb-6969-62f2-8075-99834ae11234"
}
]
You can use Subject Query Endpoint
POST https://vssps.dev.azure.com/{organization}/_apis/graph/subjectquery?api-version=6.0-preview.1
Body should look like this:
{
"query": "Term to search (e.g. Krzysztof)",
"subjectKind": [ "User" ]
}
and then you will get response like this:
{
"count": 3,
"value": [
{
"subjectKind": "user",
"metaType": "member",
"domain": "Windows Live ID",
"principalName": "mail#mail.com,
"mailAddress": "mail#mail.com",
"origin": "msa",
"originId": "0006BFFDBC3FE9A1",
"displayName": "Krzysztof Madej",
"_links": {
"self": {
"href": "https://vssps.dev.azure.com/thecodemanual/_apis/Graph/Users/msa.MDQ5MGM0N2ItODNiNC03MmEzLTk2MzgtZTJhMmNjOTY3NWQ3"
},
"memberships": {
"href": "https://vssps.dev.azure.com/thecodemanual/_apis/Graph/Memberships/msa.MDQ5MGM0N2ItODNiNC03MmEzLTk2MzgtZTJhMmNjOTY3NWQ3"
},
"membershipState": {
"href": "https://vssps.dev.azure.com/thecodemanual/_apis/Graph/MembershipStates/msa.MDQ5MGM0N2ItODNiNC03MmEzLTk2MzgtZTJhMmNjOTY3NWQ3"
},
"storageKey": {
"href": "https://vssps.dev.azure.com/thecodemanual/_apis/Graph/StorageKeys/msa.MDQ5MGM0N2ItODNiNC03MmEzLTk2MzgtZTJhMmNjOTY3NWQ3"
},
"avatar": {
"href": "https://dev.azure.com/thecodemanual/_apis/GraphProfile/MemberAvatars/msa.MDQ5MGM0N2ItODNiNC03MmEzLTk2MzgtZTJhMmNjOTY3NWQ3"
}
},
"url": "https://vssps.dev.azure.com/thecodemanual/_apis/Graph/Users/msa.MDQ5MGM0N2ItODNiNC03MmEzLTk2MzgtZTJhMmNjOTY3NWQ3",
"descriptor": "msa.MDQ5MGM0N2ItODNiNC03MmEzLTk2MzgtZTJhMmNjOTY3NWQ3"
},
as next ise originId in reviewers collection.
You can use Identities - Read Identities API to get user id. For example:
Get https://vssps.dev.azure.com/{org}/_apis/identities?searchFilter=General&filterValue=cece dong&api-version=6.1-preview.1
I'm trying to remove the pooling and integrate webhooks in the process of file conversion. The problem is that the webhook is created but the callback is never called back.
I'm following the instructions from here: https://forge.autodesk.com/en/docs/webhooks/v1/tutorials/create-a-hook-model-derivative/
The web server is started by the following command : ngrok http host-header=rewrite https://localhost:44366
The callback is http://f36a47b8.ngrok.io/derivative and is up and running. Post requests from postman(internal network) and Post requests from external networks (cellular data) are reaching the endpoint and are successfully redirected.
A hook is created:
"hookId": "51897b50-522a-11ea-b885-f34f23e3435e",
"tenant": "c0761189-32dd-4ca3-9e52-3ae400f91651",
"callbackUrl": "http://f36a47b8.ngrok.io/derivative",
"createdBy": "HUpqLPysSUmbFGlhQo0uG8XMqimfQnRG",
"event": "extraction.updated",
"createdDate": "2020-02-18T08:40:29.829+0000",
"system": "derivative",
"creatorType": "Application",
"status": "active",
"scope": {
"workflow": "c0761189-32dd-4ca3-9e52-3ae400f91651"
},
"urn": "urn:adsk.webhooks:events.hook:51897b50-522a-11ea-b885-f34f23e3435e",
"__self__": "/systems/derivative/events/extraction.updated/hooks/51897b50-522a-11ea-b885-f34f23e3435e"
}
Than a call to modelderivative/v2/designdata/job is issued with the following content:
var job = new JobRequest
{
Input = new Input
{
Urn = urnBase64,
},
Output = new Output
{
Formats = new List<Format>
{
new Format
{
Type = "svf",
Views = new List<string> { "2d", "3d" }
}
},
Destination = new Destination { Region = "EMEA" }
},
Misc = new Misc
{
Workflow = workflowId
}
};
The response is success with an urn (like before);
And from that point nothing follows from the webhook. The callback is never reached, even though that within some time the file is converted and it can be loaded in the viewer as before.
I've viewed those topics:
Unable to receive Forge webhooks, or unable to get them to fire
Why is webhook workflow not taken into consideration when creating modelderivative job?
but they didn't helped.
What am i missing ?
It turns out that there is a problem with jobs for derivative API in 'EMEA' region where no callbacks are called when a job finishes. Changing the region to 'us' fixes the issue and callback is hit when a job event occurs.
From the documentation example change the region parameter:
curl -X 'POST' \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Authorization: Bearer PtnrvrtSRpWwUi3407QhgvqdUVKL' \
-H 'x-ads-force: false' -v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/job' \
-d
'{
"input": {
"urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWxkZXJpdmF0aXZlL0E1LnppcA",
"compressedUrn": true,
"rootFilename": "A5.iam"
},
"output": {
"destination": {
"region": "us" <- Change the region form 'EMEA' to 'us'
},
"formats": [
{
"type": "svf",
"views": [
"2d",
"3d"
]
}
]
}
}'
From the WebHook documentation for a store/customer/address/updated/store/customer/address/created events should have following payload:
{
"scope": "store/customer/address/created",
"store_id": "1025646",
"data": {
"type": "customer",
"id": 60,
"address": {
"customer_id": 32
}
},
"hash": "416ca9c01779515de91824aa1cac9012ee691e7a",
"created_at": 1561481620,
"producer": "stores/{store_hash}"
}
However, in the logs we don't see the "address" part. The payload is always coming as:
{
created_at: 1573847377
data: {
id: 2246136
type: "customer"
}
hash: "%hash%"
producer: "%producer%"
scope: "store/customer/address/updated"
store_id: "%storeid%"
}
And the payload.data.id is not the customer id, as fetching customer by given ID always results in 404.
Fetching address with given id is also impossible, as the resource url should include customer_id which is absent in the response.
Contacted BigCommerce support already, but maybe someone had solved this issue already?
Saw relevant question in the BigCommerce's community, but it was also unanswered.
I have encountered a similar problem, and believe I have isolated the conditions under which it occurs.
I am building an app with MEAN stack that uses bigcommerce API/webhooks.
When I tried to create a customer address in-app, it makes an API request to BigCommerce and creates customer addresses in BigCommerce. Via the webhooks, I have implemented the store_customer_address_created hook event.
So there are two cases when the address webhook event is being triggered:
When the customer address is created in-app and it sends an address creation request via the API to BigCommerce.
When the customer address is directly created in the BigCommerce admin.
Here are the responses from those:
"scope": "store/customer/address/created",
"store_id": "1025646",
"data": {
"type": "customer",
"id": 60,
},
"hash": "416ca9c01779515de91824aa1cac9012ee691e7a",
"created_at": 1561481620,
"producer": "stores/{store_hash}"
}
{
"scope": "store/customer/address/created",
"store_id": "1025646",
"data": {
"type": "customer",
"id": 60,
"address": {
"customer_id": 32
}
},
"hash": "416ca9c01779515de91824aa1cac9012ee691e7a",
"created_at": 1561481620,
"producer": "stores/{store_hash}"
}
As you can see, the address field is not included when the customer address is being created by the API. I’m not sure if it is designed by the BigCommerce team, or a special case. But I think we can identify if the customer address is being created by the BigCommerce admin directly or via the API myself based on this distinction.
I believe you are encountering the first case on your end.
I hope this helps and please update me if you have any other opinions.
It is fairly strange to see this webhook response without the address field, and I haven't had any luck replicating this with scope for store/customer/address/updated. Are you working with any other code beyond this webhook or testing the webhook event specifically?
I followed the subscription api(https://www.instagram.com/developer/subscriptions/) and created a subscription request like this:
curl -F 'client_id=clientId' \
-F 'client_secret=clientSecret' \
-F 'object=user' \
-F 'aspect=media' \
-F 'verify_token=my-verify-token' \
-F 'callback_url=https://xx.xx.com/igwh' \
https://api.instagram.com/v1/subscriptions/
and got response as bellow:
{
"meta": {
"code": 200
},
"data": {
"object": "user",
"object_id": null,
"aspect": "media",
"subscription_id": 0,
"callback_url": "https://xx.xx.com/igwh",
"type": "subscription",
"id": 0
}
}
My app is in live mode, so is that normal to get the "object_id": null, "subscription_id": 0 and "id": 0 onto the response?
After that when my another authenticated instagram account shared a media then I got notification to my callback url but seems to me lack of information:
[
{
"changed_aspect": "media",
"object": "user",
"object_id": "111111",
"time": 1484290271,
"subscription_id": 0,
"data": {
"media_id": "1111-11"
}
}
]
I said lack of information because a media have "id", "images", "caption", "link" etc which I was expecting as a response.
Because otherwise I have to call normal api(Media enpoints) call again to get those things. Is there anything I missed to get the subscription or have different way to get?
https://www.instagram.com/developer/subscriptions/
this endpoint says "When we have new data, we'll POST this data to your callback URL. We'll explain more about what this URL needs to do later on this page."
Although I can't get the subscription api response if I comment on the media(which I had got the notification in my callback url) or liked on the media/comment.
Is that those things not supported by instagram? Does anyone have this issue or any help will be appreciated?
May be this answer of mine will be helpful to people having same problem.