#StackBounty: #java #spring #rest #apache-camel #resttemplate REST service call with Camel which requires authentication api called first

Bounty: 50

Camel has to call REST service for some integration, However, the REST service has one authentication api (POST api) which needs to be called first to get a token and then other subsequent api calls has to be invoked with the token embedded in header of HTTP requests.

Does Spring Restemplate or apache camel has some api to support the same?


Get this bounty!!!

#StackBounty: #php #mysql #database #rest #codeigniter Create API endpoint for fetching dynamic data based on time

Bounty: 50

I have a scraper which periodically scrapes articles from news sites and stores them in a database [MYSQL].
The way the scraping works is that the oldest articles are scraped first and then i move onto much more recent articles.

For example an article that was written on the 1st of Jan would be scraped first and given an ID 1 and an article that was scraped on the 2nd of Jan would have an ID 2.

So the recent articles would have a higher id as compared to older articles.

There are multiple scrapers running at the same time.

Now i need an endpoint which i can query based on timestamp of the articles and i also have a limit of 10 articles on each fetch.

The problem arises for example when there are 20 articles which were posted with a timestamp of 1499241705 and when i query the endpoint with a timestamp of 1499241705 a check is made to give me all articles that is >=1499241705 in which case i would always get the same 10 articles each time,changing the condition to a > would mean i skip out on the articles from 11-20. Adding another where clause to check on id is unsuccessful because articles may not always be inserted in the correct date order as the scraper is running concurrently.

Is there a way i can query this end point so i can always get consistent data from it with the latest articles coming first and then the older articles.

EDIT:

   +-----------------------+
   |   id | unix_timestamp |
   +-----------------------+
   |    1 |   1000         |
   |    2 |   1001         |
   |    3 |   1002         |
   |    4 |   1003         |
   |   11 |   1000         |
   |   12 |   1001         |
   |   13 |   1002         |
   |   14 |   1003         |
   +-----------------------+

The last timestamp and ID is being sent through the WHERE clause.

E.g.
$this->db->where('unix_timestamp <=', $timestamp);
$this->db->where('id <', $offset);
$this->db->order_by('unix_timestamp ', 'DESC');
$this->db->order_by('id', 'DESC');

On querying with a timestamp of 1003, ids 14 and 4 are fetched. But then during the next call, id 4 would be the offset thereby not fetching id 13 and only fetching id 3 the next time around.So data would be missing .


Get this bounty!!!

#StackBounty: #magento2 #rest Magento2: Save Product Data for global scope using Rest API

Bounty: 50

I am trying to add product using Rest API. Adding product is working fine.

But I am facing issue in assign in the product informtaion only for Default values instead of coying data for store view. When we select store view Use Default Value checkbox must be checked. Only one attribute value must save in database with scope 0 instead of copying same values for each store.

How can I acheive the above scenario using Rest API ? Below is what I have tried so far:

Case 1:

I tried to call API using the below URL, But It replicate the product values for store view.

POST   /rest/V1/products

Case 2:

I tried to call API using the below URL, But It also replicate the product values for store view.

POST   /rest/{store_code}/V1/products

Case 3:

I tried to call API using the below URL

POST   /rest/all/V1/products

using the above website not assigned to product. so I called catalogProductWebsiteLinkRepositoryV1 to assign product in website as below, but it also replicate the product values for store view.

POST   /rest/V1/products/{sku}/websites

Please suggest how can we save product data for global scope only ?

Note: only have one website, one store and one store view in magento installtion.


Get this bounty!!!

#StackBounty: #8 #rest CSRF token time life

Bounty: 50

I’ve get CSRF token from url /rest/session/token. After have CSRF token, I can send request (get, post) to API and working fine. But after time, when I send request. It’s doesn’t work. I’m getting error permission denies. I think maybe CSRF token expire time. So I want know time life of CSRF token. And how to change time life of CSRF token.


Get this bounty!!!

#StackBounty: #rest #onedrive #onedrive-api Downloading and Moving OneDrive files from shared link directory

Bounty: 100

I am looking for assistance to find out how I can download and move a OneDrive file that is accessed through a shared directory, via the shared link method of sharing.

I have two users:

  • user ‘A’ who is a Microsoft Consumer and has a regular OneDrive account and will host a csv file ‘test.csv’ in a folder ‘toshare’
  • and user ‘B’ who is also a regular Microsoft Consumer who should use the graph API to download test.csv and then move the file to a subdirectory /toshare/archive

Aside: I am currently using the chrome app “advanced REST client” to manually make the REST calls, and am getting Authenticated OAuth BEARER tokens by inspecting network traffic from Microsoft’s online “Graph Explorer” tool. After we understand the calls, we’ll integrate it into our Java app.

I have succesfully followed the instructions here:
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/shares_get
to view the folder contents.

To be more explicit, user ‘A’ has went into OneDrive and has right clicked the folder ‘toshare’ and selected shareLink. I have converted the shareLink to a share token and then used the following API call with the Graph API as user ‘B’:

GET https://graph.microsoft.com/v1.0/shares/<share-token>/root?$expand=children

this shows me all the files in the directory, which includes ‘test.csv’

Now, using this information, how can I download test.csv? Assuming user ‘B’ doesn’t know the name of the file, but can identify it by being a .csv file (we can do this in code). There does not appear to be much documentation on how to download the files through a share.

The closest I’ve gotten was to take the “webUrl” attribute of the children object for my file, and then turn that into a share token and call

GET https://graph.microsoft.com/v1.0/shares/<child-share-token>/root

This will show me the file meta-data. and then I try to download it by roughly following the api documentation to download https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/item_downloadcontent

GET https://graph.microsoft.com/v1.0/shares/<child-share-token>/root/content

This is interesting because this works if I make the call with user ‘A’ but does not work for user ‘B’ who instead gets a 403 in advanced REST client. (If I run it in Graph Explorer, I get “The site in the encoded share URI is invalid.” instead, which I’ve discovered with other experimentation, really means there’s an authorization issue.)

At this point I’m rather stuck. After downloading the file, I also would like to move it into a subdirectory, denoting that it has already been read in. I’d also like to get this working for OneDrive for Business, but that seems to be another set of challenges that I’ll leave for another day.

Any insight would be great thanks,
Jeremy


Get this bounty!!!

#StackBounty: #magento-2.1 #api #rest #search #solr Magento Integration with Solr

Bounty: 50

I have integrated Solr with Magento EE. Solr logs whatever I search in Magento fronted search box.

I’d like to know if Magento will also use Solr engine if the search REST API is called?


Get this bounty!!!

#StackBounty: #2013 #javascript #rest #discussion-board Working with Discussions/Replies using REST update DiscussionLastUpdated

Bounty: 100

I’m following this thread which shows how to create a reply to a discussion using REST api. Basically — created the reply at top level of list, get the reply parent folder, get the FileRef info about the reply, and move the reply under the parent.

That is all working well and the replies appear in the right spot and the parent discussion shows the correct number of replies.

I’m trying to update the Last updated column which has an internal name of DiscussionLastUpdated on the parent so that it can move to the top of our “recent” discussions list. It isn’t updating — neither through the rest calls, nor if I create a child reply through the UI.

I found threads like this which talk about permissions, and I will work on that problem later, but since I am only working with my stuff at the moment AND I am site collection admin with full control over everything….well I don’t think that is currently the issue.

After a lot of work I finally found that I can update the Modified date with

var payload = { '__metadata': { "type": _listEntityName },
                DiscussionLastUpdated: new Date().toJSON()
}
return $.ajax({ url: _webUrl + "/_api/web/lists/getbytitle('"+_listName+"')/Items("+itemId+")",
                type: "POST",
                data: JSON.stringify(payload),
                headers:headers.MERGE
})

Even though I’m updating DiscussionLastUpdated, it is the Modified date that is updated.

Does anybody know how to update the Last updated/DiscussionLastUpdated independent of the Modified date?

EDIT: Bonus Question

There is also a LastReplyBy or LastReplyById which I can’t seem to set either. There may well be other “rollup-to-the-parent-thread” features that I haven’t noticed either. If anyone knows about this in REST or even JSOM please share.


Get this bounty!!!

#StackBounty: #8 #rest Understand about login Drupal 8 REST API

Bounty: 50

I was reading article. I would to like know follow of login with REST API in Drupal 8. Default, when user login from form, Drupal will be check user name, password… and verify. After login, browser have a cookie like that

enter image description here

If same browser user don’t need login again and I can check current user. But with REST API, how can Drupal 8 can verify user for first time login and after login how to check current login.


Get this bounty!!!

#StackBounty: #magento-1.7 #database #api #rest #performance Creating an API to communicate directly with Magento DB

Bounty: 50

We have been using the Magento Rest API to communicate between external systems and Magento. Painfully, we have discovered that the REST API does not scale well. Specifically, often times requests time-out when requesting large amounts of data (say, about fifty products). We are using version 1.7.0.2.

One solution we are investigating is creating a custom API not written using Magento for the purpose of reading/writing into Magento.

  • Is this a solution typically used?
  • If so, any packages that simplify read/write operations from Magneto EAV tables?
  • If not, are there any ways to speed up the Magento REST API?

We are in the process of scaling and speed is very important to us.


Get this bounty!!!

#StackBounty: #java #json #rest #javafx #response The registered message body readers compatible with the MIME media type are: applicat…

Bounty: 50

I’m using Spring Rest API in server side and jersey API from client side.

I’m creating a screen where it will fetch last 5 customer redeem transaction.

From server side i’m returning list of RedeemTransactionDetails and accepting the same in client side.

I had debugged server side code it’s returns the valid list,
and in client side response code is 200 , whereas while getting
entity i’m getting error from client side.

Server side:

    @RestController
    @RequestMapping("/rest/api")
    public class CustomerRestController {
            @Autowired private CustomerService customerService;

            @RequestMapping(value="/redeemTransactionList/{clientId}/{mobileNumber}/{numOfTransaction}" , method=RequestMethod.POST , produces = "application/json; charset=UTF-8")
            public @ResponseBody List<RedeemTransactionDetails> redeemTransaction(@PathVariable(value = "clientId") int clientId, @PathVariable(value = "mobileNumber") String mobileNumber , @PathVariable(value="numOfTransaction") int numOfTransaction) {
            LOG.debug("We are in redeemTransaction method for user {} " , clientId);
            List<RedeemTransactionDetails> redeemList = null ;
            try {
                redeemList =  customerService.redeemTransactionList(clientId, mobileNumber,numOfTransaction);

            } catch (Exception e) {
                LOG.debug("Excption while fetching redeemTransaction ");
            }
            return  redeemList;
        }
    }

Client Side :

public List<RedeemTransactionDetails> getRedeemTransactions(String mobileNumber, String clientId, String numberOfTransaction) {
    log.debug("inside authenticate() ");
    List<RedeemTransactionDetails> result = null; 
    try{
        webResource = client.resource(uri + "/redeemTransactionList").path(clientId).path(mobileNumber).path(numberOfTransaction) ;
        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class);
        if (response.getStatus() != 200) {
            log.debug("response.getStatus() : " +  response.getStatus() );  
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
         } 
        response.getType() ;
        result = (List<RedeemTransactionDetails>) response.getEntity(RedeemTransactionDetails.class);
        log.debug("user Details " + result);
    }
    catch(Exception e){
        log.debug(e);
    }
    return result ;
}
}

NOTE: I had used the following dependencies in pom xml file

<dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.19.3</version>
    </dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.8.6</version>
</dependency>

EDIT:

ERROR LOG

SEVERE: A message body reader for Java class com.prom.via.rest.dto.RedeemTransactionDetails, and Java type class com.prom.via.rest.dto.RedeemTransactionDetails, and MIME media type application/json;charset=UTF-8 was not found
Feb 23, 2017 4:52:17 PM com.sun.jersey.api.client.ClientResponse getEntity
SEVERE: The registered message body readers compatible with the MIME media type are:
*/* ->
  com.sun.jersey.core.impl.provider.entity.FormProvider
  com.sun.jersey.core.impl.provider.entity.StringProvider
  com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
  com.sun.jersey.core.impl.provider.entity.FileProvider
  com.sun.jersey.core.impl.provider.entity.InputStreamProvider
  com.sun.jersey.core.impl.provider.entity.DataSourceProvider
  com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
  com.sun.jersey.core.impl.provider.entity.ReaderProvider
  com.sun.jersey.core.impl.provider.entity.DocumentProvider
  com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
  com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
  com.sun.jersey.core.impl.provider.entity.EntityHolderReader


Get this bounty!!!