Hi I am currently using balanced payments in my meteor application. I can create cards and customers just fine and I can associate the cards to the customers just fine. I run into a problem though when I try to create a debit. Here is the code that I have written which is pretty much taken directly from the balanced docs.
var customer = balanced.Customers.get(user.customer.uri, function (err, customer) {
console.error(err);
console.log(customer);
var customerContext = balanced.Customers.nbalanced(customer);
var debitInfo = {
amount: amount,
appears_on_statement_as: "Statement text",
description: "Some descriptive text for the debit in the dashboard"
};
customerContext.Debits.create(debitInfo, function(err, result) {
console.error(err);
console.log(result);
});
});
I get the error "The requested URL was not found on the server" whenever the above code runs. I found the problem but I'm not entirely sure how to solve it. I went to the balanced dashboard to check the logs and what I found was this.
Date: Fri, 27 Sep 2013, 6:46 AM
Method: POST
URI: /v1/marketplaces/TEST-MPFj4MYWjZc9xt2IjTIni7/v1/customers/CU6jgv9FlavhPyYQ6ObZKDny/debits
Status: 404 NOT FOUND
The request body is here:
{
"appears_on_statement_as": "Statement text",
"amount": 1200,
"description": "Some descriptive text for the debit in the dashboard"
}
Here is the response body:
{
"status": "Not Found",
"category_code": "not-found",
"description": "<p>The requested URL was not found on the server.</p><p>If you entered the URL manually please check your spelling and try again.</p> Your request id is OHM38291020277b11e38b38026ba7cac9da.",
"status_code": 404,
"category_type": "request",
"_uris": {},
"request_id": "OHM38291020277b11e38b38026ba7cac9da"
}
I see that the URI has the marketplace and customer url but I don't know why or what could have caused that to happen because like I said the customer creation, card creation and card association calls all work perfectly.
Any advice would be appreciated.
The balanced api documentation over at https://docs.balancedpayments.com/current/api#create-a-new-debit suggests there is an issue with the requested URL.
The URL in the api module you're using requests
/v1/marketplaces/TEST-MPFj4MYWjZc9xt2IjTIni7/v1/customers/CU6jgv9FlavhPyYQ6ObZKDny/debits
when it should be
/v1/customers/CU6jgv9FlavhPyYQ6ObZKDny/debits
It could also be that it needs the marketplaces uri in there, but there isn't a specification in the docs that matches this type of pattern, plus the '/v1/` suggests its being appended unnecessarily
You haven't given details on the type of package you're using but the issue for this lies in the package in the portion that creates the request URI, or if its not validated perhaps in one of the parameters you've provided.
Related
I am integrating the hubspot API to track user interaction with our site. I am creating dynamic lists and I want to filter a user into a certain contact list by which URL they visit.
"filters": [
[
{
"operator": "CONTAINS",
"property": "hs_URL",
"value": `${id}`
},
],
]
I keep getting this error for all my attempts:
{"status":"error","message":"Couldn't find a Property with the given name 'hs_URL'","correlationId":"0723dcee-534b-4f92-9104-509d6885abbe","propertiesErrorCode":"PROPERTY_NOT_FOUND"},
I cannot seem to find a master property list and have tried many string combinations. Anyone familiar with hubspot property lists would be my savior.
Thank you~!
It's been a few months, so you may not need this anymore, but since I landed here while looking for a way to get all the properties from an object type in hubspot using nodejs, this might help others looking for the solution.
The master list of properties can be retrieved with the following API call:
const response = await hubspotClient.crm.properties.coreApi.getAll(objectType, false);
The arguments for getAll() expect:
objectType: a string, i.e "contacts".
archived: a boolean, i.e false. Set this true if you want to get archived properties.
The following code was adapted based on this page from the hubspot API docs:
https://developers.hubspot.com/docs/api/crm/properties
Once you're on the page, you can click on the "Endpoints" Tab to reveal code snippets for multiple environments, including nodejs.
For this example, getProperties(), retrieves all properties for a given object type. I used contacts for the object type, which I believe is where you are storing the url property, but you could use the same function to get properties for other object types such as companies or deals.
It might be worth noting that I mapped the results to return just the property names, which sounds like all you need for your case, but more information is contained in the results if you need it. Just remove this bit to get more information on each property:
.map(prop => prop.name)
const hubspot = require('#hubspot/api-client')
const hubspotClient = new hubspot.Client({ apiKey: "YOUR_API_KEY" })
const getProperties = async (objectType) => {
try {
const response = await hubspotClient.crm.properties.coreApi.getAll(objectType, false);
return response.body.results.map(prop => prop.name);
} catch (e) {
e.message === 'HTTP request failed'
? console.error(JSON.stringify(e.response, null, 2))
: console.error(e);
}
}
Here's an example for running the function to get a list of all property names for contacts.
(async () => {
var properties = await getProperties("contacts");
console.log(JSON.stringify(properties ,null,2));
})();
It took me a bit to find this, so figured I would post here in the hopes it saves time for someone else. This is the first time I've posted a solution, and I'm pretty new to this API and Hubspot in general, so feedback and/or better solutions are welcome. Cheers.
In my angular app I want to use the stripe-API. I want to add a payment method to the customer. e.g. SEPA
My first Problem is to choose the right endpoint. I think it is the "create source"-endpoint.
My second problem is to pass the correct params. My postman body looks like
{
type: 'sepa_debit',
sepa_debit: {iban: 'DE12345678901234567890'},
currency: 'eur',
customer: 'cus_Jjg6mhSRHZuXYZ'
owner: {
name: 'Max Mustermann',
}
Response:
"error": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameters: type, sepa_debit",
"param": "type",
"type": "invalid_request_error"
}
the docs says that type can be 'sepa_debit'...?
Can someone pls hepl me?
You should use Payment Methods API instead of Sources API. If you have an existing Payment Method, you can attach it to a Customer.
You can also create a Payment Method, attach it and start a new payment flow at the same time when creating a Payment Intent.
Is there a way to fix this MailChimp API error in Node.js?
{
type: 'http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/',
title: 'Invalid Resource',
status: 400,
detail: "The resource submitted could not be validated. For field-specific details, see the 'errors' array.",
instance: '95a2824e-4f30-4ce4-8c5e-322859d933e4',
errors: [
{
field: 'members.item:0.status',
message: 'Data presented is not one of the accepted values: subscribed, unsubscribed, cleaned, pending.'
}
]
}
What is the API call the Node app is trying to do? Looks like its trying to add a member to a list, so assuming you are making this request POST /lists/{list_id}/members
The required fields in the body needs to be:
{
"email_address": "",
"status": ""
}
Based on the error message, you are not passing in a status in the POST request. Possible values are the following: "subscribed", "unsubscribed", "cleaned", "pending", or "transactional".
So I want to use the Instagram API to get a specific user's (NOT MY USER) recent media. Instagram has the following endpoint for doing so:
(GET) https://api.instagram.com/v1/users/{user-id}/media/recent/?access_token=ACCESS-TOKEN
This is a problem because I do not have the user's ID (why would I, Instagram?). What I do have is the account username (as most people would), e.g. #thisisauser.
I've been reading the API docs and I can't find an endpoint that will give me the user ID for a specific account username. I mean, yes, there is:
(GET) https://api.instagram.com/v1/users/search?q=jack&access_token=ACCESS-TOKEN
...but it doesn't do what I need it to do, which is to search for an exact match.
I've also checked out other threads on Stack Overflow and other websites. However, the alternative solutions offered are, at best, questionable.
The fact that this whole thing is an actual issue surprises me. I mean, SURELY there's a legitimate, Instagram-approved, precise and straightforward way of either:
obtaining a user's recent media by providing the account username (which is what people know you by... not a sequence of numbers)
OR
obtaining a user's ID via an exact match search, with no chance of multiple possible results
FYI: I'm doing this server-side, using PHP and cURL.
Side note: If I have to make a separate request to the API in order to convert an account username to a user ID, that's just a waste of a request, one more for the hourly limit. Just an observation, in case any member of the Instagram team happens to see this.
You can get all of a user's information (including the id) by requesting this URL:
https://www.instagram.com/{username}/?__a=1
For example, this gets you all of the information related to the account taylorswift:
https://www.instagram.com/taylorswift/?__a=1
I couldn't find anything in the API that gets a username's media. However, by using the search endpoint, you can come up with a solution to get a user's media.
Since you're using PHP cURL, you could do something like this:
//this is what was returned by cURL
$response = /*what was returned by the API - see below*/
{
"data": [{
"username": "jack",
"first_name": "Jack",
"profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_66_75sq.jpg",
"id": "66",
"last_name": "Dorsey"
},
{
"username": "sammyjack",
"first_name": "Sammy",
"profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_29648_75sq_1294520029.jpg",
"id": "29648",
"last_name": "Jack"
},
{
"username": "jacktiddy",
"first_name": "Jack",
"profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_13096_75sq_1286441317.jpg",
"id": "13096",
"last_name": "Tiddy"
}]
}
//username I am looking for
$user = 'jack';
//filter array response to find exact username you are looking for
$filter = array_filter($response,function($userdata) use ($user){
if($userdata['username'] == $user){
return $userdata;
}
});
//now use ID from filtered array to get media
$url = 'https://api.instagram.com/v1/users/' . $filter['id'] . '/media/recent/?access_token=ACCESS-TOKEN';
you can find user id !!!
like this :
<html>
<head>
<script src="jquery.js" type="text/javascript" ></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type: 'GET',
url: 'https://api.instagram.com/v1/users/self/?access_token=' + window.location.hash.substring(14),
dataType: 'jsonp'}).done(function(response){
var userid = response.data.id;
});
});
</script>
</head>
<body>
</body>
</html>
and save in to your data base .then when need find it and use that way to find recent media of user :
https://api.instagram.com/v1/users/{user-id}/media/recent/?access_token=ACCESS-TOKEN
this way i think is beter.
you can send a json with php too.
Hello im working on a instagram api, i don't know how to solve a problem. You can see my problem here down:
I want to get all photos by a tag. by now, i just can get recent photos (no more than 19 results)
$api = "https://api.instagram.com/v1/tags/".$hashtag."/media/recent?client_id=".$client;
how can i make it work?
Instagram API will not return all photos with a single API call, each call I think returns a maximum of 20 photos. After making the first API call, you have to use the "next_url" in "pagination" of JSON response to make another API call to get the next set of 20 images, for example you may have to implement a "show more" button which will load the next set and so on.
Below is a typical response you get from a instagram API, then making a request to API url at pagination.next_url will return you the next set of photos.
{
"meta": {
"code": 200
},
"data": {
...
},
"pagination": {
"next_url": "...",
"next_max_id": "13872296"
}
}