LinkedIn API "Company Follow" how to Start follow a company - c#

Everyone,
I am implementing Linkedin API now. Most API request works fine. But I had met a problem for "Start Follow a company":
POST
http://api.linkedin.com/v1/people/~/following/companies
This is the request sample LinkedIn give, but there is no place to put id parameter, how to tell LinkedIn that which company I want to follow ?
I tried to use the similar one with Stop following, but it didnt work...
DELETE
http://api.linkedin.com/v1/people/~/following/companies/id={id}
Is any one know how to use it ?
Thank you.

From the docs, to get a list of companies the current user is following, you do:
GET
http://api.linkedin.com/v1/people/~/following/companies
To start following a company, you do:
POST
http://api.linkedin.com/v1/people/~/following/companies
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<company>
<id>{id}</id>
</company>
To stop following you have it correct:
DELETE
http://api.linkedin.com/v1/people/~/following/companies/id={id}
You can play around with these on the REST Console to get familiar with them.

Related

Accessing OneDrive from Desktop App

I'm trying to get to grips with OneDrive, using this tutorial:
https://msdn.microsoft.com/en-us/library/hh826529.aspx
When I run in code, it gets as far as the makeAccessTokenRequest function, sending the following requestURL:
"https: //login.live.com/oauth20_token.srf?client_id=[myclientID] &client_secret=[myclientsecret]&redirect_uri=https:// login.live.com/oauth20_desktop.srf&grant_type=authorization_code&code=[authcode]"
(please ignore the spaces after "https:", I had to add them here to allow the question)
[myclientid], [myclientsecret], and [authcode] all appear to be populated correctly. It seems to get a response, as it runs the function "accessToken_DownloadStringCompleted", but throws a "TargetInvocationException" error, The inner message of the error is ""The remote server returned an error: (400) Bad Request.".
Could anyone throw any light on this? I'm completely new to this, so apologies if my question makes no sense, or is irritatingly vague..
Requests to the oauth20_token.srf end point need to be a POST with the parameters in the body of the post, instead of the query string. Since you didn't mention what code you're using to build the HTTP request it's hard to provide an example, but take a look at RedeemAuthorizationCodeAsync in my sample OAuth 2 project for an idea.
The outgoing request should look like this:
POST https://login.live.com/oauth20_token.srf
Content-Type: application/x-www-form-urlencoded
client_id={client_id}&redirect_uri={redirect_uri}&client_secret={client_secret}&code={code}&grant_type=authorization_code
You may also find this tutorial easier to follow than the one you linked with: https://dev.onedrive.com/auth/msa_oauth.htm.
If you are doing something with OneDrive (you tagged the post OneDrive) then you may want to consider using the OneDrive SDK instead. It includes authentication for several types of .NET projects so you don't need to figure out how to do auth yourself.

SOAP Request and Response with ASP.NET using the WSDL URL As Web Service?

Ok, installed Visual Web Developer 2008, Created a Website as ASP.net (C# Language), than added a Service to it via the following URL: http://ws.idssasp.com/members.asmx?wsdl and after hitting Go, looks like this (I change the namespace to ServiceMembers):
Now it looks like this:
If I than go to Default.aspx.cs file, How do I use this on Page Load? I want something to be outputted from the Service on Page Load, ofcourse, will need to call something else via a button, but really just need a way to get anything from this service to be outputted... How to do this?
Looking here: http://ws.idssasp.com/members.asmx there are a bunch of methods that resemble the pic above, but how to use them anywhere? When I try to do Response.Write(ServiceMembers.GetCategoryListResponse); if gives error that this is a Type and can not be used in that way. How do I use anything here?
Also, I will need to pass a Username and Password into the initial SOAP POST to that URL (which I have), before I can get anything back as a Response, but how? Looks like I should use ServiceMembers.AuthorizeHeader somehow? But how? Looking at the Request XML from this page here for GetCategoryList, has this listed in the XML:
<soap:Header>
<AuthorizeHeader xmlns="http://ws.idssasp.com/Members.asmx">
<UserName>string</UserName>
<Password>string</Password>
</AuthorizeHeader>
</soap:Header>
But how to do this via code to the server? Unknown!
I don't see GetCategoryList Method as an option for ServiceMembers namespace anywhere, but there is GetCategoryListRequest Type and GetCategoryListResponse Type as options for ServiceMembers via the last pic. How do I invoke Methods of a Service? How do I use any of this for this step in the process? I have read so many tutorials on this, but nothing that I've seen explains how to do this without error of some sort, or different situations than mine.
Can anyone start me out with just simple code on outputting anything from this Web Service? Anything at all? Everyone is saying to use Visual Web Developer as it will do the Bulk of the work for you, but no one is explaining how to use any Web Service that you install. Seems that they only explain on how to use Specific things in Web Services, it's like they aren't teaching you to fish in an ocean of fish, but instead setting you up to fail, with a fish in a bucket that you are sure to catch.
What is the next step here? I didn't create this Web Service, and I don't know how to use it in the ASP.NET Website either.
The GetCategoryList method is in MembersSoapClient class and you need to create an instance of MembersSoapClient to use GetCategoryList. Try this in your Page_Load method:
protected void Page_Load(object sender, EventArgs e)
{
AuthorizeHeader authorizeHeader = new AuthorizeHeader();
authorizeHeader.UserName = "yourusername";
authorizeHeader.Password = "yourpassword";
MembersSoapClient client = new MembersSoapClient();
Category[] categories = client.GetCategoryList(authorizeHeader);
}

How to use Yahoo REST Api in C#

I'm just trying to make an yahoo boot that send to registered user of my application an instant message. I've spent some hours searching the web on how to do it but yahoo developer documentation sucks.First of all I don't know what servers I should use for authorization, log in, and messaging. I have a consumer key and I've tried to follow this steps but nothing works.
Any advice/suggestion is welcome.
The documentation looks to be very good, I think the issue here is that your knowledge of how REST API's work in general is a bit lacking.
Let's talk about diagram #2: Get a request token using: get_request_token.
get_request_token is part of an HTTP endpoint, and in their diagram they want you to pass in a handful of parameters to validate your request.
oauth_consumer_key
oauth_nonce
oauth_signature_method
etc
(If you need more clarification of any step you can find it in the tree view on the left hand side of the page)
The request URL:
https://api.login.yahoo.com/oauth/v2/get_request_token.
Now at this point you can either use the HTTP GET or POST verb. If you decide to use GET you will need to include those above parameters as a query string.
?oath_consumer_key=myConsumerKey&oauth_nonce=oathNonce etc
I will leave it to you to write the associated C# code. You'll want to start off with the HttpWebRequest.Create() method

LinkedIn API 401 Unauthorised when using Field Selectors

I am attempting to get specific information from the user's profile via the LinkedIn API.
The URL I am using for the GET call is the following:
http://api.linkedin.com/v1/people/~:(id,first-name,last-name,industry,headline,public-profile-url)
When attempting this I get a "401 Unauthorized" response from the server. However, when I do a GET to http://api.linkedin.com/v1/people/~ within the same function with the same auth keys, etc. it works just fine.
The error presented in the response is as follows:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
<status>401</status>
<timestamp>1316082986700</timestamp>
<request-id>SVWTG5ARQM</request-id>
<error-code>0</error-code>
<message>[unauthorized].</message>
</error>
Any ideas of why this might be happening? Anything would be greatly appreciated.
It is likely your OAuth library is buggy. Can you view the full request and response?
I would make sure your Authorization / OAuth header has the same signature as the one generated from this tool:
https://developer.linkedin.com/oauth-test-console
If not, you'll need to get a new library, update/fix your library, etc.
If yes, then that is weird. Come back and we'll go from there :)

WCF web http Service doesnt return xmlns

I have created a simple REST web service.. Responses are like
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfTableCategories xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
using this attribute
[XmlSerializerFormat]
However I see no xmlns there... like tempuri...
but when try to make a request I get 400 error if I don't define xmlns="http://tempuri.org" at root element..
Any explanation for this behavior?
This is the same problem as in your last 2 questions.
We have often seen that a WCF service is not able to have a List as a return parameter.
Follow the answer that I gave in this question: Cannot deserialize with XMLSerializer result from WCF webservice

Categories