Read all projects within Project Online using web part Sharepoint

Hello all. Can we get data of all projects from Project Online in Sharepoint Site? So far as I understand we can get data of list like this:
SPWeb web = SPContext.Current.Web;
SPList issueList = web.GetList("https://tenant.sharepoint.com/sites/demo/Sample Project 1/Lists/Issues/AllItems.aspx");
Do you have any some good tutorial? I am new on web part Sharepoint.
Thanks in advance.

Hello,
Yes you can, I would use the ProjectData API if you are not bothered about security (accessing all projects etc.) or if you want the data returned to be accessed controlled use the ProjectServer API. Examples below:
ODATA API (ProjectData):
<PWA site URL>/_api/ProjectData/Projects
JSOM REST API (ProjectServer):
<PWA site url>/_api/ProjectServer/Projects
Regarding guides, just search for SharePoint apps / App part / client web part. Some simple examples of using  the APIs mentioned in JavaScript on the Project sites can be seen below:
https://gallery.technet.microsoft.com/scriptcenter/Server-Information-ab10fd63
https://gallery.technet.microsoft.com/scriptcenter/Server-Milestones-f8be71b8
https://gallery.technet.microsoft.com/scriptcenter/Online-Server-on-a-page-1b1f14f5
Paul
Paul Mather | Twitter |
http://pwmather.wordpress.com | CPS

Similar Messages

  • Creating chart from web part sharepoint 2013 online

    hello, my name is peter and i know to solve the problem with creating charts from web part . i am familiar with excell services, but it doesnt solve my problem because it is not taking data from web parts so it is static. Thank you for your time

    If you want info about creating charts in web parts, this one is quite nice:
    http://social.technet.microsoft.com/wiki/contents/articles/17614.adding-charts-to-standard-webparts-and-visual-webparts.aspx
    If you're worrying about getting data from another web part, you need to use web part connections and start here:
    http://msdn.microsoft.com/en-us/library/ms469765(v=office.14).aspx
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

  • Remove the scroll bar of excel sheet in excel web access web part sharepoint 2010

    Hi All,
    i am using excel web access in sharepoint 2010. but when i insert excel file in this its showing me 2 scroll bar. one for sharepoint page which is easy to remove and second in excel file.
    so i want to remove the excel sheets scroll bar not for pages scroll bar.
    i have tried all things like adjust height width and all things but unable to remove scroll bar for
    excel file.
    Please give some soln or steps for this. Please reply ASAP.
    Thanks
    Vivek

    Hi Vivek,
    You tried almost all possible ootb way to achive your goal, but contact inside excel file and browser compatibility restrict you to adjust height and width using web part properties.
    You can try below article and include that script to fix this 
    https://www.nothingbutsharepoint.com/sites/eusp/Pages/jquery-for-everyone-dynamically-sizing-excel-web-parts.aspx
    Let us know if this helps, thanks
    Regards,
    Pratik Vyas | SharePoint Consultant |
    http://sharepointpratik.blogspot.com
    Posting is provided AS IS with no warranties, and confers no rights
    Please remember to click Mark As Answer if a post solves your problem or
    Vote As Helpful if it was useful.

  • Send Email to Anonymous user thoruhg Sharepoint online custom web part

    Hi All
    Can you please suggest me how we can send Email to anonymous user?
    I have create the custom contact us web part as a sandbox solution (For SharePoint Online public facing site) with following fields
    Name: txtName
    Email: txtEmail
    Phone No: txtPhoneNo
    Company Name: txtCompany
    Message: txtMessage
    Now I want to send the Email (txtEmail) to anonymous user which have fill the contact us form.
    Note:  I am using SharePoint Online public facing site
    Thanks
    Deepak Chauhan
    SharePoint 2010 & 2013 and Office-365 Branding and Front End Customization, UI Design

    Hi Mokhtar
    I have solved my problem Email send properly but i am using SharePoint online site when
    we log In and then fill the contact us form so that mail send properly but when anonymous user fill the contact us form without log In so
    that Email not send can you please suggest me how workflow work for anonymous user 
    Thanks
    Deepak
    Chauhan
    SharePoint 2010 & 2013 and Office-365 Branding and Front End Customization, UI Design

  • How to read data from info path in custom web part in share point 2010

    We have a document library where the some info paths (code info paths) are uploaded with different views. Is there any way to read the data from info paths forms in custom share point 2010 web parts like  using any available  web services in share
    point 2010 etc,,
    Any suggestions are helpful to me.
    TARUN

    Hello,
    Yes, you can use XmlDocument, XmlNodeList, XmlElement, XmlNode etc to read infopath file via code. Just add "using System.Xml" as reference in your solution.
    Refer below link with sample code:
    https://sujeewaediriweera.wordpress.com/2012/02/12/accessing-infopath-form-data-programmatically/
    http://sharepoint2010tutor.blogspot.sg/2012/01/programmatically-reading-contents-of.html
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Creating an O365 SharePoint Online 2013 Web Part control (that is NOT on another domain or inside an IFrame)

    We created SharePoint App that offers a Web Part we can add to SharePoint 2013 pages.  The problem is that web part installs as an iframe pointing to the apps domain. 
    Two challenges in trying to impact the Page's DOM and elements and also accessing the pages URL query string parameters. Basically cross domain issues.
    Is there any way to deploy a webpart that installs in-line as a component on the page like a Script Editor Web Part?
    If that must be done as a sandbox solution, how can users on 100+ sites easily download and install this web part like web parts from the App catalog and Store?
    BTW, How is it that a Script Editor Web Part installs in-line on the page without an iframe?  Possible to reproduce this in our own App?

    SharePoint 2013 apps are designed to be secure and must run outside of the SharePoint domain. They typically are HTML, JS and CSS and any custom compiled code is run on another web server and access via web services.
    The Script Editor Web Part is a code based (compiled) "traditional" web part that runs in the SharePoint process. If you are working on premise (i.e. not Office 365), and your SharePoint admins will permit custom code to deployed to their servers,
    then you can still create SharePoint 2010 style web parts. These can be deployed as "full trust" web parts or sandbox web parts. Full trust web parts are installed on the web servers while sandbox web parts need to be uploaded to a gallery
    in each site collection (not each site). If your 100+ sites are in a single site collection, then only one upload is needed. If you have 100+ site collections then you could use PowerShell to deploy the sandbox solution to all of them.
    Mike Smith TechTrainingNotes.blogspot.com
    Books:
    SharePoint 2007 2010 Customization for the Site Owner,
    SharePoint 2010 Security for the Site Owner

  • How to dynamically change link in Page Viewer Web Part SharePoint 2010?

    Newbie Question:
    Situation:
    a) Created: Two Site Pages page 1 & page 2
    b) Page 1: Includes simple hyperlink text Example - Home | About Us | Contact etc
    c) Page 2: Includes Page Viewer Web Part that includes link to an existing web site (this site has all of the pages) and the olde site is shown in SharePoint site
    Complication:
    a) I want the users to click on Page 1 - About Us etc
    b) The View on Page 2 - page viewer link should be dynamically updated to About Us . If user clicks on contact us on Page 1..the page 2 view should change dynamically to Contact US
    ASK:
    a) How do I dynamically update the links in Page Viewer web part using minimal coding (if possible)
    Any Guidance will be greatly appreciated.

    Hello,
    You can also used the another appoch,
    Create your custom webpart , then add the PageViewer Webpart at run time,Create webpart property for the custom webpart to change the url and add the PageViewer webpart runtime,
    I have created the custom webpart property to specified the url at the tine of edit the webpart
    Here is the code
    using System;
    using System.ComponentModel;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    using System.Collections;
    using Microsoft.SharePoint.Publishing.WebControls;
    using Microsoft.SharePoint.WebPartPages;
    namespace MyNameSpace.MyPageViewer
    [ToolboxItemAttribute(false)]
    public class MyPageViewer : System.Web.UI.WebControls.WebParts.WebPart
    private string _customUrl = "http://yourdefaulturl";//Specified default url
    [WebBrowsable(true)
    , Personalizable(true)
    , Bindable(true)
    , Browsable(false)
    , DefaultValue("")
    , Category("Custom Page Viewer Properties")
    , WebPartStorage(Storage.Shared)
    , FriendlyName("PageViewer URL")
    , Description("PageViewer URL")]
    public string CustomUrl
    get { return _customUrl; }
    set {if (string.IsNullOrEmpty(value) == false) { _customUrl = value; } }
    #endregion
    public MyPageViewer()
    this.ChromeType = PartChromeType.None;
    protected override void OnInit(EventArgs e)
    EnsureChildControls();
    base.OnInit(e);
    protected override void CreateChildControls()
    string pageViewerUrl = CustomUrl;
    Microsoft.SharePoint.WebPartPages.PageViewerWebPart pageViewerWebPart = new Microsoft.SharePoint.WebPartPages.PageViewerWebPart();
    if (!string.IsNullOrEmpty(pageViewerUrl))
    pageViewerWebPart.ContentLink = pageViewerUrl;
    pageViewerWebPart.ChromeType = PartChromeType.None;
    pageViewerWebPart.Height = "382";
    pageViewerWebPart.Width = "682";
    this.Controls.Add(pageViewerWebPart);
    protected override void OnLoad(EventArgs e)
    base.OnLoad(e);
    protected override void OnPreRender(EventArgs e)
    base.OnPreRender(e);
    Hope this will help you
    Hiren Patel | Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

  • Hiding subsites in Table of Contents Web Part - SharePoint 2010

    I've gone through the normal steps of having the table of contents web part not show a subsite (uncheck the box that says "Show Hidden Sites" as well as hide the site in the global navigation) but for whatever reason, the site I've hidden still
    appears in the table of contents. Is there any way to remove it without deleting the subsite entirely?
    Thoughts?

    Actually, a version of Nate's solution did work for me, it just needs more details.....
    Where you need to check off "Show Subsites" is in the "Current Navigation" section of SiteSettings/Navigation, and then hide the sites from THERE in Navigation Editing and Sorting  (I had already tried it on the Global Navigation side
    and the subsites still appeared in the Table of Contents).  
    For our particular needs, we did NOT want those sites on this root site navigation sidebar as well, so after setting the specific subsites to "Hidden" and saving changes, I went back to SiteSettings/TreeView and unchecked "Enable Quick Launch".
     All appears on the Root Site TOC as desired.
    So, Nate was right about the whole counter-intuitive thing, but no need for custom css or de-activating/activating the publishing  features
    --VS

  • Creating a new project with custom fields using web services

    I've been trying unsuccessfully for the last week or so to successfully create a new project from web services and I believe the main problem that I've been running into is that one of the required fields is a custom field. I've tried creating the Project
    in a couple of different ways and haven't had any success up to this point, so any help would be appreciated. I've tried creating it with both a REST call to /_api/ProjectServer/Projects and a SOAP call to /_vti_bin/PSI/Project.asmx. Below are the best shots
    I've made at the two different calls with the errors I received. If anyone has any leads on the best way to do this the help would be appreciated!
    REST POST /_api/ProjectServer/Projects
    'odata.type' : 'PS.PublishedProject',
    'Name' : 'OData Name',
    'Custom_9d77d62aa92e4d40adc8446c90eb7456' : "O&M"
    Response
    error: {
    code: "11713, Microsoft.ProjectServer.PJClientCallableException"
    message: {
    lang: "en-US"
    value: "PJClientCallableException: CustomFieldRequiredValueNotProvided CustomFieldRequiredValueNotProvided mdpropuid = 9d77d62a-a92e-4d40-adc8-446c90eb7456"
    SOAP POST /_vti_bin/PSI/Project.asmx
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:proj="http://schemas.microsoft.com/office/project/server/webservices/Project/" xmlns:projds="http://schemas.microsoft.com/office/project/server/webservices/ProjectDataSet/">
    <soapenv:Header />
    <soapenv:Body>
    <proj:QueueCreateProject>
    <proj:dataset>
    <ProjectDataSet xmlns="http://schemas.microsoft.com/office/project/server/webservices/ProjectDataSet/">
    <Project>
    <PROJ_UID>e1c2d38b-1529-4128-b707-42a94045e55b</PROJ_UID>
    <PROJ_NAME>Proj Dept Test 2</PROJ_NAME>
    <PROJ_TYPE>0</PROJ_TYPE>
    </Project>
    <ProjectCustomFields>
    <CUSTOM_FIELD_UID>4802a711-62a0-4f84-8e08-c7d22daadb5b</CUSTOM_FIELD_UID>
    <PROJ_UID>e1c2d38b-1529-4128-b707-42a94045e55b</PROJ_UID>
    <MD_PROP_UID>9d77d62a-a92e-4d40-adc8-446c90eb7456</MD_PROP_UID>
    <FIELD_TYPE_ENUM>21</FIELD_TYPE_ENUM>
    <CODE_VALUE>a47930d6-b89d-4f3a-b4e3-522015fe82a1</CODE_VALUE>
    </ProjectCustomFields>
    </ProjectDataSet>
    </proj:dataset>
    <proj:validateOnly>true</proj:validateOnly>
    </proj:QueueCreateProject>
    </soapenv:Body>
    </soapenv:Envelope>
    Response
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
    <s:Fault>
    <faultcode>s:Server</faultcode>
    <faultstring xml:lang="en-US">ProjectServerError(s) LastError=GeneralUnhandledException Instructions: Pass this into PSClientError constructor to access all error information</faultstring>
    <detail>
    <errinfo>
    <general>
    <class name="General Unhandled Exception in _Project.QueueCreateProject_">
    <error id="42" name="GeneralUnhandledException" uid="184feeaf-906a-e411-9b2a-00155d388b02" Exception="System.Data.StrongTypingException: The value for column 'PROJ_TYPE' in table 'Project' is DBNull. ---> System.InvalidCastException: Specified cast is not valid.
    at Microsoft.Office.Project.Server.Schema.ProjectDataSet.ProjectRow.get_PROJ_TYPE()
    --- End of inner exception stack trace ---
    at Microsoft.Office.Project.Server.Schema.ProjectDataSet.ProjectRow.get_PROJ_TYPE()
    at Microsoft.Office.Project.Server.BusinessLayer.Project.FixupProjectType(ProjectDataSet projDS)
    at Microsoft.Office.Project.Server.BusinessLayer.Project.QueueCreateProject(Guid jobUid, ProjectDataSet dataset, Boolean validateOnly)
    at Microsoft.Office.Project.Server.Wcf.Implementation.ProjectImpl.&lt;>c__DisplayClasse.&lt;QueueCreateProject>b__d()
    at Microsoft.Office.Project.Server.Wcf.Implementation.WcfMethodInvocation.InvokeBusinessObjectMethod(String businessObjectName, String methodName, IEnumerable`1 actions)"/>
    </class>
    </general>
    </errinfo>
    </detail>
    </s:Fault>
    </s:Body>
    </s:Envelope>

    Julie,
    You can create the fields that are project specifc & you can create fields that apply to all projects but have specific options for projects. Your goal is to create fields that are specific to each project, but right now you get all fields from you old project - is this correct?
    From your description below it appears that the fields in your original project are marked as applied to all projects & hence when you create a new project they are inherited. If you mark those fields as applied to certain project & then create a new project those fields will not be inherited.
    But you are right in the sense that it is limiting that there is no multi-select for "applies to" field.

  • How can I open all webpages within one window, using tabs?

    As new user I am missing the opportunity to open a link with a new tab. Firefox opens it often within a new window. Using CTRL can solve it, but I'm not used to that.
    I used IE and IE has a setting to open everything within a new tab, instead of in a new window.
    Is something like that possible for Firefox?
    (I read something like that some website needs to be opened with a new window, because it would show better. To me that is nonsense, because I can decide for myself how to open a page.)
    So please add a setting for that, I think it would please more people than just me.
    TIA,
    Jaap

    In the Tools menu select Options to open the options window. In the options window go to the Tab panel and make sure the setting "Open new windows in a new tab" is selected.
    Firefox only has a small number of tab settings listed on the Options window, you can get far greater control over tabbed browsing by using an add-on. Some examples that greatly enhance tabbed browsing features are:
    * [https://addons.mozilla.org/en-US/firefox/addon/1122/ Tab Mix Plus]
    * [https://addons.mozilla.org/en-US/firefox/addon/59961/ Tab Utilities]
    * [https://addons.mozilla.org/en-US/firefox/addon/13288/ Super Tab Mode]
    * [https://addons.mozilla.org/en-US/firefox/addon/14439/ Tabberwocky]
    For more tab related add-ons go to https://addons.mozilla.org/en-US/firefox/extensions/tabs/

  • Project Server Performance report using SSRS - Report display issue

    Hi All,
    We have developed and deployed a SSRS report in Project Server BI Center using performance dashboard, but half of the report only visible i.e. it is showing horizontal scroll bar at the bottom as below. I tried to change the web part width and height but
    there is no difference. I also tried to change the performance point dashboard height and width but faced same issue. 
    Thanks in advance, Arun

    As Per me their is not way to deal this issue. When you use web part and deploy SSRS  RDL in project server horizontal bar display in the bottom if display area is not enough to display the data.
    whatever height or width you choose in web part property it will come.
    We have to live with this problem .
    kirtesh

  • How do I import any extension file within project in netbeans ?

    Can anybody tell that how can I add any text file or any extension file in netbeans project as I can import image within project and I can use that image when I run jar file..I do not have to move that image where I run my jar file..It will automatically take that image file from jar file...I want this thing same for files...In which I can read and write within project....(I m using netbeans 6.0 and jdk 1.6)
    Thanks...

    Thank you for yr prompt reply.
    May i try to explain once again.. I want a way to store a file (*.txt) in a package called "files" within my project. Now after compiling and making an executable jar of this project i wish to read and write to this *.txt file lying within files package. Though I m able to read this *.txt file ( with the help of getClass().getResourceAsStream() ) but i m unable to make any changes to this file within xxx.jar.
    ex:
    FileWriter fw = new FileWriter("c:/xxx.jar!/files/xyz.txt");
    Do u have ny idea? how can i do this ?
    can u plz suggest the correct forum for netbeans. Thanks once again.

  • Web part created on a subsite for a sharepoint list in another site using sharepoint designer, to show only the subsite's reports. Connection dropping off and showing all the reports

    I crated web parts in the sub-sites (we have about 10 subsites) using sharepoint designer from a main list in another site.  Then used web part to show only the  ubsite's reports - using connection to the main list.  Problem is, the connection
    is dropping off and showing all the reports on the main list that are confidential.  this has happened 3 time lately.  Could someone explain why it happens some times?  I had to fix it by adding the web part again and connecting it
    Thanks, Subathy.

    Hi George,
    If you want to use a top level site "department" list column in all sub-sites, you can go to top level site and create a
    lookup type "Site column" to look up the value from the department list, then all sub-sites can use this lookup type site column created in top level site.
    Thanks 
    Daniel Yang
    TechNet Community Support

  • Add Right Side Column and Web Parts to custom Master page in SharePoint Online

    Hello everyone, 
    I hope this is a simple question, however I was fighting the issue it presents for a while. I am in the process of customizing SharePoint Online Look-and-feel with a new layout.
    The site collection was created as a
    Team Site before I got involved with the project, and populated with numerous sub-sites and pages. I activated required
    publishing features, created html with corresponding styles and graphics, and used the Design Manager to convert the html file to the custom Master page. While SharePoint automatically assigned “ContentPlaceHolderMain” div area, I
    also used default Oslo page as example to copy sections of the code for dynamic components (left column and navigation, recent items, the ribbon, etc.) from it and placed them in my new master page, pointed all CSS references to
    my custom style sheets, etc. Everything works great, however I need to make one last addition -
    my task is to make changes to display web parts such as Calendar and Recent Documents in the right column in the Master page.
    My custom layout has a header, footer, main pan and two side columns. Most of the default master templates come with the LEFT column already embedded and populated with several placeholder
    to serve dynamic content (PlaceHolderLeftNavBarTop, PlaceHolderQuickLaunchTop, PlaceHolderLeftNavBarDataSource, PlaceHolderLeftActions, so on).
    My challenge is that I have the RIGHT side column as well, for which I don’t think the default placeholder exists. I need to add a small Calendar box and Recent Documents parts to it, so they
    display across the entire site governed by this master page.
    The issue is –
    even after activating Publishing features (enabled SharePoint Server Publishing Infrastructure under Site Collection Level, and SharePoint Server Publishing under the Site
    Level), there is no Snippet feature (usually available under the generic Publishing Site); this customization of the Team Site allows using Designer and apply custom templates, themes, so on, just like you would under the Publishing collection, but not the
    Snippet utility I could use as the solution to embed the web parts on the master page.
    Recreating the entire site under Publishing Collection is not an option due to the directions I was given, I am to use this existing one, and need to see if
    there is a workaround to either activate the Snippet feature or use another solution to display the web parts inside of the column in the Master page.
    If the only solution is to use Web Part Zone, what are the steps to add it AND populate it with the abovementioned apps?
    Can anyone suggest how to create a workaround and add this feature? The environment is role-based so both elements need to be dynamically rendered based on the user’s role and activities.
    I am more of a front end designer than developer, so if any custom coding and set up required, please kindly provide some basic steps, if possible?..
    I greatly appreciate any help and suggestions!
    Thank You!
    Jeff
    Jeff V.

    Updating your Master Page to also include a right rail should be sraight forward enough with a new div or divs in your master page and then the proper styles to make room for this column as well as position the column.
    I have not seen why you cannot find the snippet gallery link when previewing a HTML Master Page in the browser. Have you tried loading the snippet gallery by its url? As an example, for my tenant on SPO, I can load the Snippet Gallery for the olso.master
    with the following url:
    https://pixelmill.sharepoint.com/_layouts/15/ComponentConfigureControls.aspx?ComponentName=TopNavigationNoFlyoutWithStartNode&Url=%2F_catalogs%2Fmasterpage%2Foslo.master
    Change the domain to match yours as well as update the "Url" querystring var to point to your master page. See if that loads the snippet gallery.
    Eric Overfield - PixelMill -
    ericoverfield.com -
    @EricOverfield

  • Uploading multiple documents into sharepoint list item with REST in sharepoint 2013 using content editor web part :

    hi ,
    i am trying to upload multiple document files into sharepoint list item. I followed below link for implementaion.
    http://techfindings-prem.blogspot.in/search/label/jquery.multifilejs
    It was working for sharepoint hosted app.
     This complete code is written within content edito web part.
    It was working when i was in root site collection with below change (hard coded the root level url) in code in "UploadFile" function.
    var scriptbase = "http://servername" + "/_layouts/15/";
                console.log(' File size:' + bytes.length);
                $.getScript(scriptbase + "SP.RequestExecutor.js", function () {
                    var createitem = new SP.RequestExecutor("http://servername");
                    createitem.executeAsync({
                        url: "http://servername/sites/cpg/" + "/_api/web/lists/GetByTitle('SalesRecord')/items(" + attachmentitemid + ")/AttachmentFiles/add(FileName='"
    + fileName + "')",
                        method: "POST",
                        binaryStringRequestBody: true,
                        body: binary,
                        success: fsucc,
                        error: ferr,
                        state: "Update"
                    function fsucc(data) {
                        //alert( data.statusText + "\n\n" + data.responseText);
                        console.log(data + ' uploaded successfully');
                        deferred.resolve(data);
                    function ferr(data) {
                        //alert( data.statusText + "\n\n" + data.responseText);
                        console.log(fileName + "not uploaded error");
                        deferred.reject(data);
    But the issue came in picture when i was working with the other site collection instead of root one. The url was like below.
    "http://servername/sites/cpg/". This time i need to be there within "cpg" site collection. 
    Now if i hard code the url as i did above my code gets break here while come to below line
     $.getScript(scriptbase + "SP.RequestExecutor.js", function () {
    I am getting error when i used below code:
    var scriptbase = "http://servername" + "/_layouts/15/";
     $.getScript(scriptbase + "SP.RequestExecutor.js", function () {
                    var createitem = new SP.RequestExecutor("http://servername");
                    createitem.executeAsync({
                        url: "http://servername/sites/cpg/" + "/_api/web/lists/GetByTitle('SalesRecord')/items(" + attachmentitemid + ")/AttachmentFiles/add(FileName='"
    + fileName + "')",
                        method: "POST",
                        binaryStringRequestBody: true,
                        body: binary,
                        success: fsucc,
                        error: ferr,
                        state: "Update"
                    function fsucc(data) {
                        //alert( data.statusText + "\n\n" + data.responseText);
                        console.log(data + ' uploaded successfully');
                        deferred.resolve(data);
                    function ferr(data) {
                        //alert( data.statusText + "\n\n" + data.responseText);
                        console.log(fileName + "not uploaded error");
                        deferred.reject(data);
    Please hekp in this case. This complete code is written within content edito web part. 
    Regards:
    Sanjay Joshi

    Hi,
    According to your post, my understanding is that you have an issue about upload multiple documents files into library vai REST API.
    As you have said, you have used the hard code url in your code.
    How about use the _spPageContextInfo.webAbsoluteUrl method to get the url?
    I have used this method to get the url, then use the code in the article you have pasted within a content editor web part to upload the files.
    You can replace the hard code url with the _spPageContextInfo.webAbsoluteUrl method, then check whether it works.
    Thanks,
    Jason
    Jason Guo
    TechNet Community Support

Maybe you are looking for