What is the magento url for posting SOAP request - magento

Below is my code
WebClient wc = new WebClient();
using(var response = wc.OpenRead("http://templatebar.com/QA/performancetesting/enterprise1_10_0_2/magento/index.php/api/v2_soap?wsdl=1"))
{
StreamReader sr = new StreamReader(response);
string result = sr.ReadToEnd();
}
var loginRequest = string.Format(XElement.Load(AppDomain.CurrentDomain.BaseDirectory + #"XMLFiles\login.xml").ToString(),"apikey","apipassword");var loginRequest = string.Format(XElement.Load(AppDomain.CurrentDomain.BaseDirectory + #"XMLFiles\login.xml").ToString(),"admin","abcd.1234");
var response1 = wc.UploadString("", loginRequest);
My question is what should be the "address" in UploadString function so that the login request gets the desired result i.e,Magento Session id
If I use this "http://templatebar.com/QA/performancetesting/enterprise1_10_0_2/magento/index.php/api/v2_soap?wsdl=1"
URL again then I get the list of wsdl services available,which is the same as in response variable.
Please Help,
Thanks.

According to the provided wsdl, the endpoint location is: http://templatebar.com/QA/performancetesting/enterprise1_10_0_2/magento/index.php/api/v2_soap/index/
(source: check the wsdl:service location for it. The url is written in the location-element)

Related

Yammer "Follow in Inbox" API support

My company has created a Yammer application that we use internally. Our app automatically subscribes people to various threads that have been created. We have found that there is a difference between "subscribing" someone to a thread and what happens when a user clicks the "follow in inbox" link on the site. When we automatically subscribe people, the only thing that we can see happening is that the thread will appear in the users "Following" section in the Home tab. Contrast this with what happens when a user clicks the "Follow in Inbox" link. From that point on any comments added to the thread will show up in the user's inbox and an email will be sent out to the user when this happens. We would really like for this to happen when we automatically subscribe someone to a thread, however, this feature seems to be missing from the REST API. Does anyone know of a way to accomplish this? The functionality provided by the subscription API endpoint is not sufficient for our purposes.
Thank you
P.S. I've sent the link to this question to several of my colleges they may respond before I get a chance to.
As a verified admin it is possible to create an impersonation token and then perform actions on behalf of the user such as join group/thread.
Note that for private groups, the group admin's are still required to approve the new member
https://developer.yammer.com/docs/impersonation
You can achieve your desired behaviour by adding users directly to the groups.
A C#.Net example I use:
// Impersonate user to join group
string ClientID = ConfigurationSettings.AppSettings["ClientID"]; // ClientID of custom app.
string userid = XMLDoc.Root.Element("response").Element("id").Value; // Yammer user id (in this case retreived from a previous API query)
string YammerGroupID = "123456"; // set group id.
string url = "https://www.yammer.com/api/v1/oauth/tokens.json?user_id=" + userid + "&consumer_key=" + ClientID; // impersonation end-point
HttpWebRequest request;
request = (HttpWebRequest)WebRequest.Create(url);
request.Headers.Add("Authorization", "Bearer " + bearer); // Bearer token of verified admin running the custom app.
request.Timeout = 90000;
request.Method = "GET";
request.ContentType = "application/json";
request.Proxy = new WebProxy() { UseDefaultCredentials = true };
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
StreamReader reader = new StreamReader(responseStream);
string UserTokenJSON = reader.ReadToEnd(); // UserOAuth token as a JSON string.
string UserToken = UserTokenJSON.Substring(UserTokenJSON.IndexOf("token") + 8, 22); // Find 'token' in json string.
string temp = UserToken.Substring(UserToken.Length); // there is likely a much better way to parse out the token value, although this works.
temp = UserToken.Substring(UserToken.Length - 1);
temp = UserToken.Substring(UserToken.Length - 2);
if (UserToken.Substring(UserToken.Length) == "\\")
{ UserToken = UserToken.Substring(0, UserToken.Length); }
if (UserToken.Substring(UserToken.Length - 1) == "\"")
{ UserToken = UserToken.Substring(0, UserToken.Length - 1); }
if (UserToken.Substring(UserToken.Length - 2) == "\",")
{ UserToken = UserToken.Substring(0, UserToken.Length - 2); }
string url2 = "https://www.yammer.com/api/v1/group_memberships.json?group_id=" + YammerGroupID; // group membership endpoint,
HttpWebRequest request2;
request2 = (HttpWebRequest)WebRequest.Create(url2);
request2.Headers.Add("Authorization", "Bearer " + UserToken); // Impersonation Token
request2.Timeout = 90000;
request2.Method = "POST";
request2.ContentType = "application/json";
request2.Proxy = new WebProxy() { UseDefaultCredentials = true };
try
{
using (WebResponse response2 = (HttpWebResponse)request2.GetResponse())
{
confirmedstring += " New member: " + Email + "\\r\\n"; // This is used for posting summary back to a Yammer group in further code.
confirmedadditions++;
}
}
catch
{
Errorstring += "Error in adding " + Email + " to group " + YammerGroupID + "\\r\\n";
errors++;
}
}
}

null string parameter in body of POST request to WebAPI2 service

I have an action defined in a WebAPI2 controller as follows:
[HttpPost]
[Route("DataImport/Product/")]
public DataImportJournalEntry ImportData([FromBody] string base64)
{
return _dataImportService.Import(Convert.FromBase64String(base64));
}
and I'm building a request, using RestSharp, as follows:
var base64 = {4Kb xml file loaded and encoded to base64}
var client = new RestClient(Config.BaseAddress);
var request = new RestRequest("DataImport/Product/", Method.POST);
request.AddParameter("base64", base64, ParameterType.GetOrPost);
request.AddHeader("accepts", "application/json");
var response = client.Execute<DataImportJournalEntry>(request);
The routing is correct as the action is called but the base64 parameter is null on the server side?
Found it..when using the FromBody attribute there can be only one parameter in the body and WebAPI is looking for it as ={value} not as you would expect {key}={value}. So I simply passed the parameter name as an empty string in the test:
...
var request = new RestRequest("DataImport/Product/", Method.POST);
request.AddParameter("", base64);
...
More details here: http://encosia.com/using-jquery-to-post-frombody-parameters-to-web-api/

How to retrieve photo previews in app.net

When I have an app.net url like https://photos.app.net/5269262/1 - how can I retrieve the image thumbnail of the post?
Running a curl on above url shows a redirect
bash-3.2$ curl -i https://photos.app.net/5269262/1
HTTP/1.1 301 MOVED PERMANENTLY
Location: https://alpha.app.net/pfleidi/post/5269262/photo/1
Following this gives a html page that contains the image in a form of
img src='https://files.app.net/1/60621/aWBTKTYxzYZTqnkESkwx475u_ShTwEOiezzBjM3-ZzVBjq_6rzno42oMw9LxS5VH0WQEgoxWegIDKJo0eRDAc-uwTcOTaGYobfqx19vMOOMiyh2M3IMe6sDNkcQWPZPeE0PjIve4Vy0YFCM8MsHWbYYA2DFNKMdyNUnwmB2KuECjHqe0-Y9_ODD1pnFSOsOjH' data-full-width='2048' data-full-height='1536'
Inside a larger block of <div>tags.
The files api in app.net allows to retrieve thumbnails but I somehow don't get the link between those endpoints and above urls.
The photos.app.net is just a simple redirecter. It is not part of the API proper. In order to get the thumbnail, you will need to fetch the file directly using the file fetch endpoint and the file id (http://developers.app.net/docs/resources/file/lookup/#retrieve-a-file) or fetch the post that the file is included in and examine the oembed annotation.
In this case, you are talking about post id 5269262 and the URL to fetch that post with the annotation is https://alpha-api.app.net/stream/0/posts/5269262?include_annotations=1 and if you examine the resulting json document you will see the thumbnail_url.
For completeness sake I want to post the final solution for me here (in Java) -- it builds on the good and accepted answer of Jonathon Duerig :
private static String getAppNetPreviewUrl(String url) {
Pattern photosPattern = Pattern.compile(".*photos.app.net/([0-9]+)/.*");
Matcher m = photosPattern.matcher(url);
if (!m.matches()) {
return null;
}
String id = m.group(1);
String streamUrl = "https://alpha-api.app.net/stream/0/posts/"
+ id + "?include_annotations=1";
// Now that we have the posting url, we can get it and parse
// for the thumbnail
BufferedReader br = null;
HttpURLConnection urlConnection = null;
try {
urlConnection = (HttpURLConnection) new URL(streamUrl).openConnection();
urlConnection.setDoInput(true);
urlConnection.setDoOutput(false);
urlConnection.setRequestProperty("Accept","application/json");
urlConnection.connect();
StringBuilder builder = new StringBuilder();
br = new BufferedReader(
new InputStreamReader(urlConnection.getInputStream()));
String line;
while ((line=br.readLine())!=null) {
builder.append(line);
}
urlConnection.disconnect();
// Parse the obtained json
JSONObject post = new JSONObject(builder.toString());
JSONObject data = post.getJSONObject("data");
JSONArray annotations = data.getJSONArray("annotations");
JSONObject annotationValue = annotations.getJSONObject(0);
JSONObject value = annotationValue.getJSONObject("value");
String finalUrl = value.getString("thumbnail_large_url");
return finalUrl;
} .......

Twitterizer get user information

I have a questions on using Twitterizer
I want to get the TwitterUser model for getting the user's information from the response request on Twitter, but i don't know the way.
This is my code:
public ActionResult Logon(string oauth_token, string oauth_verifier, string ReturnUrl)
{
if (string.IsNullOrEmpty(oauth_token) || string.IsNullOrEmpty(oauth_verifier))
{
UriBuilder builder = new UriBuilder(this.Request.Url);
builder.Query = string.Concat(
builder.Query,
string.IsNullOrEmpty(builder.Query) ? string.Empty : "&",
"ReturnUrl=",
ReturnUrl);
string token = OAuthUtility.GetRequestToken(
ConfigurationManager.AppSettings["TwitterConsumerKey"],
ConfigurationManager.AppSettings["TwitterConsumerSecret"],
builder.ToString()).Token;
//return Redirect(OAuthUtility.BuildAuthorizationUri(token, true).ToString());
Response.Redirect(string.Format("http://twitter.com/oauth/authenticate?oauth_token={0}&force_login=true", token), true);
}
var tokens = OAuthUtility.GetAccessToken(
ConfigurationManager.AppSettings["TwitterConsumerKey"],
ConfigurationManager.AppSettings["TwitterConsumerSecret"],
oauth_token,
oauth_verifier);
OAuthTokens accessToken = new OAuthTokens();
accessToken.AccessToken = tokens.Token;
accessToken.AccessTokenSecret = tokens.TokenSecret;
accessToken.ConsumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"];
accessToken.ConsumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"];
//TwitterUser u =
TwitterUser myTwitterUser = ..............
..............
}
I already get the OAuthTokens.After the "........." i don't know what to do next to get the information for the user.
Anyone can help me.Thansk a lot
Did you try looking at the documentation:
TwitterResponse<TwitterUser> myTwitterUser = TwitterUser.Show(accessToken, "twit_er_izer");

How to perform a get request with RestSharp?

I'm having trouble figuring out how to make a GET request using RestSharp on Windows Phone 7. All of the examples show making a POST request, but I just need GET. How do I do this?
GET is the default method used by RestSharp, so if you don't specify a method, it will use GET:
var client = new RestClient("http://example.com");
var request = new RestRequest("api");
client.ExecuteAsync(request, response => {
// do something with the response
});
This code will make a GET request to http://example.com/api. If you need to add URL parameters you can do this:
var client = new RestClient("http://example.com");
var request = new RestRequest("api");
request.AddParameter("foo", "bar");
Which translates to http://example.com/api?foo=bar
What you're looking for is located here.
The code snippet that covers your scenario is below (request.Method should be set to Method.GET):
public void GetLabelFeed(string label, Action<Model.Feed> success, Action<string> failure)
{
string resource = "reader/api/0/stream/contents/user/-/label/" + label;
var request = GetBaseRequest();
request.Resource = resource;
request.Method = Method.GET;
request.AddParameter("n", 20); //number to return
_client.ExecuteAsync<Model.Feed>(request, (response) =>
{
if (response.ResponseStatus == ResponseStatus.Error)
{
failure(response.ErrorMessage);
}
else
{
success(response.Data);
}
});
}

Resources